private BaseLoadInfo AddInstanceAsync(string widgetName, Vector3 position, Quaternion rotation, OnObjectLoadEnd onLoadEnd) { if (hasDestroy) { return(null); } return(ResLoadMgr.singleton.ResourceLoadAsync(widgetName, (ResLoadMgr.OnLoadEnd)(loadInfo => { if (loadInfo == null || !loadInfo.GetResObject()) { Debug.LogWarning("not find instance Async[" + widgetName + "]"); return; } if (this.hasDestroy) { ResLoadMgr.singleton.UnLoadResource(loadInfo); return; } UnityEngine.Object instObj = GameObject.Instantiate(loadInfo.GetResObject(), position, rotation); if (instObj == null) { return; } instanceList.Add(InstranceInfo.make(instObj, loadInfo)); if (onLoadEnd != null) { onLoadEnd(instObj); } }))); }
private UnityEngine.Object AddInstance(string path, Vector3 position, Quaternion rotation)//, bool _DontDestroyOnLoad = false) { if (hasDestroy) { return(null); } var info = ResLoadMgr.singleton.ResourceLoad(path); if (info == null || !info.GetResObject()) { Debug.LogWarning("not find instance [" + path + "]"); return(null); } var resourceObject = info.GetResObject(); UnityEngine.Object instObj = GameObject.Instantiate(resourceObject, position, rotation); instanceList.Add(InstranceInfo.make(instObj, info)); return(instObj); }