static public void CreatGFXTexture(AssetInfo _assets, bool isCreat, List <Texture2D> textures = null) { AssetInfo info; GameObject obj; if (isCreat) { maters.Clear(); } if (textures == null) { textures = new List <Texture2D>(); } for (int i = 0; i < _assets.ChildAssetInfo.Count; i++) { info = _assets.ChildAssetInfo[i]; if (info.AssetFileType == AssetInfo.FileType.Folder) { CreatGFXTexture(info, false, textures); } else if (info.AssetFileType == AssetInfo.FileType.ValidFile && info.Extension == ".prefab" /* && info.AssetName == "Test.prefab"*/) { obj = AssetDatabase.LoadAssetAtPath <GameObject>(info.AssetPath); Renderer[] Rs = obj.GetComponentsInChildren <Renderer>(); for (int r = 0; r < Rs.Length; r++) { foreach (Material mater in Rs[r].sharedMaterials) { if (maters.Contains(mater)) { continue; } maters.Add(mater); if (mater.mainTexture != null) { textures.Add((Texture2D)mater.mainTexture); } } } } } if (isCreat && textures.Count > 0) { //得到图片的设置信息 TextureImporterSettings[] originalSets = AtlasTool.GatherSettings(textures.ToArray()); //最终打成的图集路径,包括名字 string assetPath = "Assets/CreatAssetBundle/ParticleEffects/GFXAtlas.png"; string outputPath = Application.dataPath + "/../" + assetPath; //主要的打图集代码 AtlasTool.PackAndOutputSprites(textures.ToArray(), assetPath, outputPath); maters.Clear(); } }
public static void OpenIconEditorWindows() { AtlasTool.updateAtlas(); }