IEnumerator LoadUIAssetBundle(string path, string name, CUILoadState openState) { var assetLoader = CStaticAssetLoader.Load(path); openState.UIResourceLoader = assetLoader; // 基本不用手工释放的 while (!assetLoader.IsFinished) { yield return(null); } GameObject uiObj = (GameObject)assetLoader.TheAsset; openState.IsLoading = false; // Load完 uiObj.SetActive(false); uiObj.name = openState.TemplateName; CUIController uiBase = (CUIController)uiObj.AddComponent(openState.UIType); UiBridge.UIObjectFilter(uiBase, uiObj); openState.UIWindow = uiBase; uiBase.UIName = uiBase.UITemplateName = openState.TemplateName; InitWindow(openState, uiBase, openState.OpenWhenFinish, openState.OpenArgs); }
// CSpineData 加载完后,在读取依赖的SkeletonDataAsset和SpriteCollection protected void LoadCSpineData(string path, Action <SkeletonDataAsset> dataCallback) { var loader = CStaticAssetLoader.Load(path, (isOk, obj) => { //string resourcePath = args[0] as string; //Action<SkeletonDataAsset> externalCallback = args[1] as Action<SkeletonDataAsset>; if (isOk) { CSpineData spineData = obj as CSpineData; LoadSpineDataAsset(spineData.DataAssetPath, (SkeletonDataAsset dataAsset) => { var loader2 = CTk2dSpriteCollectionDep.LoadSpriteCollection(spineData.SpriteCollectionPath, (_obj) => { tk2dSpriteCollectionData colData = _obj as tk2dSpriteCollectionData; Logger.Assert(colData); dataAsset.spriteCollection = colData; dataCallback(dataAsset); }); ResourceLoaders.Add(loader2); }); } else { Logger.LogWarning("[CSpineAnimationDep:LoadCSpineData] Not Ok {0}", path); dataCallback(null); } }); ResourceLoaders.Add(loader); }
protected void LoadSpineDataAsset(string path, Action <SkeletonDataAsset> callback) { var loader = CStaticAssetLoader.Load(path, (_isOk, _obj) => { SkeletonDataAsset dataAsset = _obj as SkeletonDataAsset; Logger.Assert(dataAsset); dataAsset.name = path; callback(dataAsset); }); ResourceLoaders.Add(loader); }
IEnumerator InitSetting() { var assetLoader = CStaticAssetLoader.Load("GameSetting" + CCosmosEngine.GetConfig("AssetBundleExt"), null); while (!assetLoader.IsFinished) { yield return(null); } CGameSettingFiles gameSetting = (CGameSettingFiles)assetLoader.TheAsset; for (int i = 0; i < gameSetting.SettingFiles.Length; ++i) { GameSettings[gameSetting.SettingFiles[i]] = gameSetting.SettingContents[i]; } CDebug.Log("{0} setting files loaded.", GameSettings.Count); Object.Destroy(gameSetting); assetLoader.Release(); LoadFinished = true; }
public static CStaticAssetLoader LoadSpriteCollection(string resourcePath, Action <UnityEngine.Object> callback) { return(CStaticAssetLoader.Load(resourcePath, (isOk, asset) => OnLoadSpriteCollectionAsset(asset, new object[] { resourcePath, callback }))); }