ItemSenceList.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using XRTool.Util;
  5. public class ItemSenceList : UnitySingleton<ItemSenceList>
  6. {
  7. public GameObject ItemSence;
  8. public GameObject CreateSenceBtn;
  9. public void Init(List<SceneConfig> scenes, SceneConfig currentScene)
  10. {
  11. for (int i = 0; i < scenes.Count; i++)
  12. {
  13. GameObject obj = Instantiate(ItemSence, transform) as GameObject;
  14. int Index = obj.transform.GetSiblingIndex();
  15. obj.transform.GetComponent<ItemSenceView>().Init(scenes[i].Id, scenes[i].SceneName, currentScene, false);
  16. }
  17. SetCreateSenceBtnBtn();
  18. }
  19. public void SetCreateSenceBtnBtn(bool isRemove = false)
  20. {
  21. int num = 0;
  22. if (!isRemove)
  23. {
  24. num = transform.childCount;
  25. }
  26. else
  27. {
  28. num = transform.childCount - 1;
  29. }
  30. if (num > 0 && num < 10)
  31. {
  32. Vector3 temppos = CreateSenceBtn.transform.localPosition;
  33. temppos.y = 1500f - num * 150f;
  34. CreateSenceBtn.transform.localPosition = temppos;
  35. }
  36. else
  37. {
  38. Vector3 temppos = CreateSenceBtn.transform.localPosition;
  39. temppos.y = 150f;
  40. CreateSenceBtn.transform.localPosition = temppos;
  41. }
  42. }
  43. public int GetSceneCount()
  44. {
  45. return transform.childCount + 1;
  46. }
  47. }