protected void ProcessUISprite(string resourcePath) { var loader = KUIAtlasDep.LoadUIAtlas(resourcePath, (atlas) => { if (!IsDestroy) { //UIAtlas atlas = _obj as UIAtlas; Debuger.Assert(atlas); Debuger.Assert(DependencyComponent); var sprite = DependencyComponent as UISprite; Debuger.Assert(sprite); sprite.atlas = atlas; //对UISpriteAnimation处理 foreach (UISpriteAnimation spriteAnim in this.gameObject.GetComponents <UISpriteAnimation>()) { spriteAnim.RebuildSpriteList(); } } OnFinishLoadDependencies(gameObject); // 返回GameObject而已哦 }); ResourceLoaders.Add(loader); }
protected void LoadTexture(string texPath, Action <Texture> exCallback = null) { TexturesWaitLoadCount++; var texLoader = KTextureLoader.Load(texPath, (isOk, tex) => { if (!isOk) { Log.LogError("无法加载依赖图片: {0}", texPath); } if (exCallback != null) { exCallback(tex); } TexturesWaitLoadCount--; if (TexturesWaitLoadCount <= 0) { foreach (var c in TexturesLoadedCallback) { c(); } TexturesLoadedCallback.Clear(); } }); ResourceLoaders.Add(texLoader); }
// UILabel... Bitmap Font protected void ProcesBitMapFont(string resPath) { // Load UIFont Prefab var loader = KStaticAssetLoader.Load(resPath, (isOk, o) => { if (!IsDestroy) { var uiFontPrefab = (GameObject)o; Logger.Assert(uiFontPrefab); uiFontPrefab.transform.parent = DependenciesContainer.transform; var uiFont = uiFontPrefab.GetComponent <UIFont>(); Logger.Assert(uiFont); var label = DependencyComponent as UILabel; //foreach (UILabel label in gameObject.GetComponents<UILabel>()) { label.bitmapFont = uiFont; } OnFinishLoadDependencies(uiFont); } else { OnFinishLoadDependencies(null); } }); ResourceLoaders.Add(loader); }
// 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 ProcessTk2dSprite(string resourcePath) { if (string.IsNullOrEmpty(resourcePath)) { Logger.LogError("[ProcessTk2dSprite]Null ResourcePath {0}", gameObject.name); return; } var loader = CTk2dSpriteCollectionDep.LoadSpriteCollection(resourcePath, (_obj) => { tk2dSpriteCollectionData colData = _obj as tk2dSpriteCollectionData; Logger.Assert(colData); if (!IsDestroy) { Logger.Assert(DependencyComponent is tk2dBaseSprite); tk2dBaseSprite sprite = (tk2dBaseSprite)DependencyComponent; sprite.Collection = colData; sprite.Build(); } OnFinishLoadDependencies(colData); // 返回GameObject而已哦 //else // Logger.LogWarning("GameObject maybe destroy!"); }); 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); }
protected void ProcessUIFont(string resPath) { var loader = KUIAtlasDep.LoadUIAtlas(resPath, atlas => { if (!IsDestroy) { Debuger.Assert(atlas); UIFont uiFont = DependencyComponent as UIFont; Debuger.Assert(uiFont); //foreach (UIFont uiFont in this.gameObject.GetComponents<UIFont>()) { uiFont.atlas = atlas; uiFont.material = atlas.spriteMaterial; } } OnFinishLoadDependencies(gameObject); // 返回GameObject而已哦 }); ResourceLoaders.Add(loader); }
// 讀SpriteCollection... protected void ProcessTileMap_LoadSpriteCollection(string path) { var loader = CTk2dSpriteCollectionDep.LoadSpriteCollection(path, (_obj) => { tk2dSpriteCollectionData colData = _obj as tk2dSpriteCollectionData; CDebug.Assert(colData); if (!IsDestroy) { var sprite = (tk2dTileMap)DependencyComponent; //foreach (tk2dTileMap sprite in gameObject.GetComponents<tk2dTileMap>()) { sprite.Editor__SpriteCollection = colData; sprite.ForceBuild(); } } OnFinishLoadDependencies(gameObject); // 返回GameObject而已哦 //else // CDebug.LogWarning("GameObject maybe destroy!"); }); ResourceLoaders.Add(loader); }