protected override void OnUnLoad() { ResourcesLoader loader = ResourceMgr.Instance.ResLoader as ResourcesLoader; if (loader != null) { loader.OnCacheDestroy(this); } if (mIsGameObject) { /* * 使用GameObject.DestroyImmediate(mTarget, true) 会导致UnityEditor中 文件的操作无法使用,以及第二次使用Resources.Load失败 * GameObject.DestroyObject 和 GameObject.Destroy, 使用GameObject.DestroyImmediate(mTarget, false)会提示使用 DestroyImmediate(mTarget, true) * 使用Resources.UnloadAsset 会提示错误:只能释放不可见的资源,不能是GameObject */ // GameObject.DestroyImmediate(mTarget, true); // GameObject.DestroyObject(mTarget); if (Application.isEditor) { LogMgr.Instance.LogWarning("ResourceAssetCache OnUnLoad: GameObject is not UnLoad in EditorMode!"); } // else // Resources.UnloadAsset(mTarget); // GameObject.DestroyImmediate(mTarget, true); } else { // texture, material etc. if (mTarget != null) { #if USE_UNLOADASSET Resources.UnloadAsset(mTarget); #endif } //if (Application.isEditor) // LogMgr.Instance.LogWarning("ResourceAssetCache OnUnLoad: GameObject is not UnLoad in EditorMode!"); //GameObject.DestroyImmediate(mTarget, true); } mTarget = null; mTargetType = null; mFileName = string.Empty; if (m_PoolUsed) { InPool(this); } else { ClearLinkListNode(); } }
protected override void OnUnUsed() { ResourcesLoader loader = ResourceMgr.Instance.ResLoader as ResourcesLoader; if (loader != null) { loader.OnCacheDestroy(this); } mTarget = null; mFileName = string.Empty; if (m_PoolUsed) { InPool(this); } }