InstantiateSystem.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using System.Collections.Generic;
  2. using Blue;
  3. using UnityEngine;
  4. using TMPro;
  5. public class InstantiateSystem : SingletonMonobehaviour<InstantiateSystem>
  6. {
  7. [SerializeField] private BlueObject blueObject;
  8. public BlueObject BlueObject => blueObject;
  9. public Dictionary<string, GameObject> objDic = new Dictionary<string, GameObject>();
  10. public void InstantiatePrefab(GameObject prefab,GameObject parent =null)
  11. {
  12. Instantiate(prefab,parent.transform);
  13. }
  14. public void InstantiatePrefab(GameObject prefab, string content = "")
  15. {
  16. if (content != "")
  17. {
  18. // 修改显示内容,并实例化到CenterCamera
  19. prefab.GetComponentInChildren<TextMeshProUGUI>().text = content;
  20. /*
  21. GameObject CenterCamera = GameObject.Find("SDKSystem/NRCameraRig/CenterCamera");
  22. if(CenterCamera!=null)
  23. Instantiate(prefab, CenterCamera.transform);
  24. */
  25. if (OpenXRCamera.Instance.head != null)
  26. Instantiate(prefab, OpenXRCamera.Instance.head);
  27. // 关闭加载界面
  28. if (objDic.TryGetValue("LoadingPanel(Clone)",out GameObject LoadingPanel))
  29. {
  30. if (LoadingPanel.activeSelf)
  31. LoadingPanel.SetActive(false);
  32. }
  33. }
  34. else
  35. Instantiate(prefab);
  36. }
  37. }