Beispiel #1
0
        public override void OnImport()
        {
            name    = GetFileName(AssetPath);
            sprites = new Sprite[0];

            GenerateAtlasTexture();

            if (SpriteImportData == null || SpriteImportData.Length == 0 || TextureImportSettings.spriteMode == (int)SpriteImportMode.Single)
            {
                SetSingleSpriteImportData();
            }

            ProcessAnimationSettings();

            GenerateTexture(AssetPath);

            ApplySpritesToAnimation();

            Context.AddObjectToAsset("Texture", Texture);
            Context.SetMainObject(Texture);

            foreach (Sprite sprite in sprites)
            {
                Context.AddObjectToAsset(sprite.name, sprite);
            }


            if (Settings.generateAnimations)
            {
                AnimationImporter animationImporter = new AnimationImporter(AsepriteFile);
                AnimationClip[]   animations        = animationImporter.GenerateAnimations(name, AnimationSettings);

                foreach (AnimationClip clip in animations)
                {
                    //AssetDatabase.CreateAsset(clip, GetPath(assetPath) + clip.name + ".asset");
                    if (clip == null)
                    {
                        continue;
                    }

                    Context.AddObjectToAsset(clip.name, clip);
                }
            }
        }