PdfList.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using XRTool.Util;
  5. public class PdfList : UnitySingleton<PdfList>
  6. {
  7. public GameObject pdfItem;
  8. public void AddItem(FileConfig fileConfig)
  9. {
  10. if (RoomFile.Instance.FilePrefabConfigList.Contains(fileConfig))
  11. {
  12. RoomFile.IfFilePrefabConfigListAction?.Invoke(fileConfig);
  13. }
  14. else
  15. {
  16. RoomFile.Instance.FilePrefabConfigList.Add(fileConfig);
  17. GameObject obj = Instantiate(pdfItem, transform) as GameObject;
  18. obj.transform.GetChild(0).transform.GetComponent<PdfManager>().Init(fileConfig);
  19. Transform filePos = RoomFile.Instance.GetFilePos();
  20. obj.transform.eulerAngles = filePos.eulerAngles;
  21. obj.transform.position = filePos.position;
  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. }