예제 #1
0
        /// <summary>
        /// 同步实例化资源
        /// </summary>
        /// <param name="assetName"></param>
        public GameObject LoadSync(string assetName, Transform parent)
        {
            PrefabObject prefabObj = null;

            if (loadedList.ContainsKey(assetName))
            {
                prefabObj = loadedList[assetName];

                prefabObj.RefCount++;

                if (prefabObj.Asset == null) // 说明在异步加载中,需要不影响异步加载,加载后要释放
                {
                    prefabObj.Asset = assetLoadMgr.LoadSync(assetName);

                    var newGo = InstanceAsset(prefabObj, parent);

                    assetLoadMgr.Unload(prefabObj.Asset);

                    prefabObj.Asset = null;

                    return(newGo);
                }

                return(InstanceAsset(prefabObj, parent));
            }

            prefabObj = new PrefabObject()
            {
                AssetName = assetName, RefCount = 1
            };

            prefabObj.Asset = assetLoadMgr.LoadSync(assetName);

            loadedList.Add(assetName, prefabObj);

            return(InstanceAsset(prefabObj, parent));
        }
예제 #2
0
 public virtual Object LoadSync(string assetName)
 {
     return(assetLoadMgr.LoadSync(assetName));
 }