Exemple #1
0
        private GameObject InstantiateSafe(AssetHandle assetHandle)
        {
            var goAsset = assetHandle.asset as GameObject;

            if (goAsset == null)
            {
                return(null);
            }
            var go = GameObject.Instantiate <GameObject>(goAsset);

            if (go == null)
            {
                return(null);
            }
            var helper = go.AddComponent <AssetRefHelper>();

            helper.RefAsset(assetHandle.assetRef);
            return(go);
        }
Exemple #2
0
 internal void OnLoadAssetSucc(AssetHandle assetHandle)
 {
     assetRefDict[assetHandle.asset.GetInstanceID()] = assetHandle.assetRef;
 }
Exemple #3
0
 //释放强引用资源
 public void ReleaseCache(AssetHandle assetHandle)
 {
     strongRefs.RemoveRef(assetHandle.assetRef);
 }
Exemple #4
0
 //缓存资源,AssetManager被销毁时才释放,提前释放需要手动释放
 //慎重调用
 public void CacheAsset(AssetHandle assetHandle)
 {
     strongRefs.AddRef(assetHandle.assetRef);
 }
Exemple #5
0
 //释放缓存的弱引用资源
 public void ReleaseWeakCache(AssetHandle assetHandle)
 {
     weakRefs.RemoveRef(assetHandle.assetRef);
 }
Exemple #6
0
 //缓存资源,切场景时自动释放
 public void WeakCache(AssetHandle assetHandle)
 {
     weakRefs.AddRef(assetHandle.assetRef);
 }