using System.Collections.Generic; using UnityEngine; namespace Game { public class PrefabManager : ManagerBase { private const string PrefabPathRoot = "Prefab/"; private Dictionary _goModuleDict = new Dictionary(); public PrefabManager() { } public override void OnCreate() { } public override void Update() { } public override void OnDestroy() { } public GameObject CreateGo(string path) { var pathReal = $"{PrefabPathRoot}{path}"; if (!_goModuleDict.ContainsKey(pathReal)) { var res = Resources.Load(pathReal); if (res is null) { Util.Print("prefab不存在:", pathReal); return null; } _goModuleDict[pathReal] = res; } return Object.Instantiate(_goModuleDict[pathReal]); } public GameObject CreateGo(GameObject goModule) { return Object.Instantiate(goModule); } } }