InstantiateSystem.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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)
  11. {
  12. Instantiate(prefab);
  13. }
  14. public void InstantiatePrefab(GameObject prefab, string content = "")
  15. {
  16. if (content != "")
  17. {
  18. // 修改显示内容,并实例化到CenterCamera
  19. prefab.GetComponentInChildren<TextMeshProUGUI>().text = content;
  20. GameObject CenterCamera = GameObject.Find("SDKSystem/NRCameraRig/CenterCamera");
  21. if(CenterCamera!=null)
  22. Instantiate(prefab, CenterCamera.transform);
  23. // 关闭加载界面
  24. if(objDic.TryGetValue("LoadingPanel(Clone)",out GameObject LoadingPanel))
  25. {
  26. if (LoadingPanel.activeSelf)
  27. LoadingPanel.SetActive(false);
  28. }
  29. }
  30. else
  31. Instantiate(prefab);
  32. }
  33. }