void innerRelease() { if (mDepends != null) { AssetRef.decRef(mDepends); mDepends = null; } if (mAssetBundle != null) { mAssetBundle.Unload(mReside == ResideType.Ref); mAssetBundle = null; } if (mAsset != null) { if (mIsPrefab) { //小心勿改,编辑模式下DestroyImmediate会删除原始资源 if (mIsAB) { GameObject.DestroyImmediate(mAsset, mIsAB); } } else { Resources.UnloadAsset(mAsset); } mAsset = null; } mAssetRef = null; mCallData = null; #if UNITY_EDITOR traceUnload(this); #endif }
void copyRef(AssetRef ar) { if (ar == null) { return; } mAsset = ar.mAsset; string[] tmp = mDepends; mDepends = ar.mDepends; addRef(); decRef(tmp); }
public static bool setImage(Image image, ResLoad rl) { if (image == null) { return(false); } AssetRef ar = image.GetComponent <AssetRef> (); if (ar == null) { ar = image.gameObject.AddComponent <AssetRef> (); } ar.copyRef(rl.depends()); image.sprite = ar.mAsset as Sprite; return(true); }
void setAssetRef(GameObject prefab) { if (prefab == null) { return; } mIsPrefab = true; if (mAssetRef != null) { return; } mAssetRef = prefab.GetComponent <AssetRef> (); if (mIsAB) { if (null == mAssetRef) { mAssetRef = prefab.AddComponent <AssetRef> (); } mAssetRef.setDepends(mDepends); } }