public override void OnPostprocessAllAssets(IAkyuiLoader loader, Object[] importAssets)
        {
            var spriteAtlasPath = spriteAtlasOutputPath.Replace("{name}", loader.LayoutInfo.Name) + ".spriteatlas";
            var spriteAtlas     = AssetDatabase.LoadAssetAtPath <SpriteAtlas>(spriteAtlasPath);

            if (spriteAtlas == null)
            {
                Debug.Log($"Create SpriteAtlas: {spriteAtlasPath}");

                AkyuiEditorUtil.CreateDirectory(Path.GetDirectoryName(spriteAtlasPath));
                spriteAtlas = new SpriteAtlas();
                AssetDatabase.CreateAsset(spriteAtlas, spriteAtlasPath);
            }

            if (source != null)
            {
                EditorUtility.CopySerialized(source, spriteAtlas);
            }

            spriteAtlas.name = loader.LayoutInfo.Name;
            spriteAtlas.Remove(spriteAtlas.GetPackables());
            spriteAtlas.Add(importAssets);

            SpriteAtlasUtility.PackAtlases(new[] { spriteAtlas }, EditorUserBuildSettings.activeBuildTarget);
        }
Пример #2
0
        public override void OnPostprocessAllAssets(IAkyuiLoader loader, Object[] importAssets)
        {
            var spriteAtlasPath = spriteAtlasOutputPath.Replace("{name}", loader.LayoutInfo.Name) + ".spriteatlas";
            var spriteAtlas     = AssetDatabase.LoadAssetAtPath <SpriteAtlas>(spriteAtlasPath);

            if (spriteAtlas == null)
            {
                Debug.Log($"Create SpriteAtlas: {spriteAtlasPath}");

                AkyuiEditorUtil.CreateDirectory(Path.GetDirectoryName(spriteAtlasPath));
                spriteAtlas = new SpriteAtlas();
                AssetDatabase.CreateAsset(spriteAtlas, spriteAtlasPath);
            }

            if (spriteAtlasPreset != null)
            {
                spriteAtlasPreset.ApplyTo(spriteAtlas);
            }

            spriteAtlas.name = loader.LayoutInfo.Name;
            spriteAtlas.Remove(spriteAtlas.GetPackables());
            spriteAtlas.Add(importAssets);

            SpriteAtlasUtility.PackAtlases(new[] { spriteAtlas }, EditorUserBuildSettings.activeBuildTarget);

            // なにかのバグだと思うんだけど、ここでSaveしないとPresetが反映されないことがある Unity 2020.3.18
            EditorUtility.SetDirty(spriteAtlas);
            AssetDatabase.SaveAssets();
        }
Пример #3
0
 private static string GetSimpleName(string name)
 {
     if (name == null)
     {
         return(string.Empty);
     }
     return(AkyuiEditorUtil.ValidFileName(name.Split('@')[0]));
 }
Пример #4
0
 public static string GetSimpleName(this XdObjectJson xdObjectJson)
 {
     if (xdObjectJson.Name == null)
     {
         return(string.Empty);
     }
     return(AkyuiEditorUtil.ValidFileName(xdObjectJson.Name.Split('@')[0]));
 }