PngJpgList.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using XRTool.Util;
  6. public class PngJpgList : UnitySingleton<PngJpgList>
  7. {
  8. public GameObject pngJpgItem;
  9. public void AddItem(FileConfig fileConfig)
  10. {
  11. if (RoomFile.Instance.FilePrefabConfigList.Contains(fileConfig))
  12. {
  13. RoomFile.IfFilePrefabConfigListAction?.Invoke(fileConfig);
  14. }
  15. else
  16. {
  17. RoomFile.Instance.FilePrefabConfigList.Add(fileConfig);
  18. GameObject obj = Instantiate(pngJpgItem, transform) as GameObject;
  19. obj.transform.GetComponent<PngJpgItem>().Init(fileConfig);
  20. obj.transform.position = RoomFile.Instance.PngJpgPoint.position + new Vector3(0, (- obj.transform.GetSiblingIndex() * 0.013f), 0f);
  21. obj.transform.eulerAngles = RoomFile.Instance.PngJpgPoint.eulerAngles;
  22. RoomFile.IfFilePrefabConfigListAction?.Invoke(fileConfig);
  23. }
  24. }
  25. public void DeleteAll()
  26. {
  27. if (transform.childCount > 0)
  28. {
  29. for (int i = 0; i < transform.childCount; i++)
  30. {
  31. Destroy(transform.GetChild(i).gameObject);
  32. }
  33. }
  34. }
  35. }