protected void LoadPrfab(string iName, AsyncLoadingPrefabComplete iCallback, bool iIsInstance, bool iIsFromResources) { m_FilePath = iName; m_IsCompelete = false; m_IsInstance = iIsInstance; if (iCallback != null) { m_PrefabLoadingCB = iCallback; } if (iIsFromResources) { GameObject _Obj = CoreTools.LoadResource <GameObject>(m_FilePath, ""); if (_Obj != null) { GameObject _TempObj = _Obj; if (m_IsInstance) { _TempObj = Instantiate(_Obj, Vector3.zero, Quaternion.identity) as GameObject; } if (m_PrefabLoadingCB != null) { m_PrefabLoadingCB(_TempObj); } _TempObj = null; } else { if (m_PrefabLoadingCB != null) { m_PrefabLoadingCB(_Obj); } } _Obj = null; Resources.UnloadUnusedAssets(); m_IsCompelete = true; } else { } }
/* * 載入Prefab並執行實體化和Callback */ protected IEnumerator LoadPrefabAsync() { GameObject _Obj = CoreTools.LoadResource <GameObject>(m_FilePath, ""); yield return(null); if (_Obj != null) { GameObject _TempObj = _Obj; if (m_IsInstance) { _TempObj = Instantiate(_Obj, Vector3.zero, Quaternion.identity) as GameObject; yield return(null); } if (m_PrefabLoadingCB != null) { m_PrefabLoadingCB(_TempObj); } _TempObj = null; yield return(null); } else { if (m_PrefabLoadingCB != null) { m_PrefabLoadingCB(_Obj); } } _Obj = null; Resources.UnloadUnusedAssets(); m_IsCompelete = true; }