SceneResMgr.cs 535 B

1234567891011121314151617181920212223242526272829
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. public class SceneResMgr : MonoBehaviour
  6. {
  7. [SerializeField] GameObject[] prefabs;
  8. public static SceneResMgr ins;
  9. void Awake()
  10. {
  11. ins = this;
  12. }
  13. void OnDestroy()
  14. {
  15. if (ins == this) ins = null;
  16. }
  17. public GameObject GetPrefab(string prefabName)
  18. {
  19. foreach (var item in prefabs)
  20. {
  21. if (item.name == prefabName) return item;
  22. }
  23. return null;
  24. }
  25. }