//-------∽-★-∽------∽-★-∽--------∽-★-∽资源相关∽-★-∽--------∽-★-∽------∽-★-∽--------// /// <summary> /// 获取assets下的图片sprite /// </summary> /// <param name="link"></param> /// <returns></returns> public static Sprite GetSprite(string link) { string atlasName = LinkTextureData.GetAtlasName(link); atlasName = AtlasBatchSetting.GetBatchedAtlasName(atlasName); //获取打包的图集 string spriteName = LinkTextureData.GetTextureName(link); string path = GetAtlasPath(atlasName); if (_cachedSpritesDict.ContainsKey(path) == false) { _cachedSpritesDict.Add(path, AssetDatabase.LoadAllAssetsAtPath(path)); } Object[] sprites = _cachedSpritesDict[path]; if (sprites.Length == 0) { throw new Exception("未找到图集: " + path); } foreach (Object obj in sprites) { if (obj.name == spriteName) { return(obj as Sprite); } } throw new Exception("未找到Sprite: " + path + " " + spriteName); }
public static void Generate(string jsonName, InputParam inputParam_) { Initialize(); _isHighQuality = inputParam_.isHighQuality; _atlasName = AtlasBatchSetting.GetBatchedAtlasName(jsonName); //获取实际的图集名称 //WriteBatchedReadme(_atlasName, jsonName); //提醒图集已经移到partxx List <string> batchedAtlasNameList = AtlasBatchSetting.GetBatchedAtlasNameList(jsonName); //收集此图集包含的所有json名称 for (int i = 0; i < batchedAtlasNameList.Count; i++) { string name = batchedAtlasNameList[i]; if (batchedAtlasNameList.Count == 1 || i > 0) //如果多于一个,跳过第一个,因为那个是目标图集,不是界面 { JsonData jsonData = KAssetManager.GetUIJsonData(name); ProcessJson(jsonData); //处理所有该图集需要用到的json, 不只是该界面的json } } //处理散图 ProcessTextureDataList(); if (_uniqueTextureDataList.Count > 0) { //需要生成图集 GenerateAtlas(); } else { Debug.Log("面板资源都在公共图集中~~~~"); } }