Exemplo n.º 1
0
        public void EndFileVisit(AseFile file)
        {
            // Add sprites to sprite atlas (or more correctly, add the scritable object that will add the sprites when import completes)
            var spriteAtlasUser = SpriteAtlasUserAsset.CreateSpriteAtlasUserAsset(m_SpriteAtlas);

            m_Context.AddObjectToAsset("__atlas", spriteAtlasUser);

            BuildAnimations();

            var renderer = m_GameObject.AddComponent <SpriteRenderer>();

            renderer.sprite           = m_Sprites[0];
            renderer.sortingLayerName = m_SortingLayerName;
            renderer.sortingOrder     = m_SortingOrder;

            var animator = m_GameObject.AddComponent <Animator>();

            animator.runtimeAnimatorController = m_AnimatorController;
            animator.cullingMode = m_AnimatorCullingMode;

            m_AseFile = null;
            m_Context = null;
            m_Palette.Clear();
            m_Layers.Clear();
            m_Frames.Clear();
            m_Sprites.Clear();
            m_Clips.Clear();
            m_AseFrameTagsChunk = null;
            m_UniqueNameifier.Clear();
            m_GameObject = null;
        }
Exemplo n.º 2
0
        public void BeginFileVisit(AseFile file)
        {
            SpriteAtlasUserAsset.RemoveSpritesFromAtlas(assetPath);

            m_AseFile = file;
            m_Pivot   = null;

            // Start off with a an empty 256 palette
            m_Palette = Enumerable.Repeat(m_TransparentColor, 256).ToList();

            // Create the array of clear pixels we'll use to begin each frame
            m_ClearPixels = Enumerable.Repeat(Color.clear, m_AseFile.Header.Width * m_AseFile.Header.Height).ToArray();

            var icon = AssetDatabaseEx.LoadFirstAssetByFilter <Texture2D>("aseprite2unity-icon-0x1badd00d");

            m_GameObject = new GameObject(Path.GetFileNameWithoutExtension(assetPath));
            m_Context.AddObjectToAsset("_main", m_GameObject, icon);
            m_Context.SetMainObject(m_GameObject);
        }