예제 #1
0
            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
            }
예제 #2
0
 void copyRef(AssetRef ar)
 {
     if (ar == null)
     {
         return;
     }
     mAsset = ar.mAsset;
     string[] tmp = mDepends;
     mDepends = ar.mDepends;
     addRef();
     decRef(tmp);
 }
예제 #3
0
        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);
        }
예제 #4
0
 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);
     }
 }