Beispiel #1
0
        /// <summary>
        /// Creates the sprites.
        /// </summary>
        /// <param name="layout">The layout.</param>
        /// <param name="startingLayer">The starting layer.</param>
        public static void CreateSprites(Layout layout, Layer startingLayer)
        {
            SpriteCreator creator = new SpriteCreator();

            creator.layout = layout;
            creator.CreateSprites(startingLayer);
        }
Beispiel #2
0
        /// <summary>
        /// Create the sprites.
        /// </summary>
        /// <param name="layout">The layout.</param>
        /// <param name="startingLayer">The starting layer.</param>
        /// <param name="spriteCollectionData">The sprite collection data.</param>
        public static void CreateSprites(Layout layout, Layer startingLayer, tk2dSpriteCollectionData spriteCollectionData)
        {
            SpriteCreator creator = new SpriteCreator();

            creator.layout = layout;
            creator.spriteCollectionData = spriteCollectionData;
            creator.CreateSprites(startingLayer);
        }
Beispiel #3
0
        /// <summary>
        /// The giant assemble button.
        /// </summary>
        void MakeAssembleButton()
        {
            GUILayout.Space(10);

            GUIContent buttonContent = new GUIContent("Assemble!");

            buttonContent.image = layout.editorGraphics.usain;
            GUIStyle buttonStyle = new GUIStyle(GUI.skin.GetStyle("button"));

            buttonStyle.padding = new RectOffset(10, 10, 10, 10);

            if (GUILayout.Button(buttonContent, buttonStyle, GUILayout.ExpandWidth(true)))
            {
                layout.startingLayer = null;
#if PS2D_TK2D
                SpriteCreator.CreateSprites(layout, null, _spriteCollectionData);
#else
                SpriteCreator.CreateSprites(layout, null);
#endif
            }

            GUILayout.Space(10);
        }
Beispiel #4
0
        /// <summary>
        /// Create a node for this layer.
        /// </summary>
        /// <param name="layer">The layer.</param>
        private void MakeAssembleFromLayerNode(Layer layer)
        {
            const int pixelsPerIndent = 15;

            // sanity
            if (layer == null)
            {
                return;
            }

            // grab the sprite layer.
            UnitySpriteLayer spriteLayer = layout.FindSpriteLayer(layer);

            if (spriteLayer == null)
            {
                return;
            }

            // don't even bother if we aren't a sprite and don't have kids
            bool deadLeaf = !spriteLayer.hasSprite && !spriteLayer.hasChildren;

            GUILayout.BeginVertical();

            GUIStyle horizontalStyle = new GUIStyle();

            horizontalStyle.padding = new RectOffset(20, 0, 0, 0);
            GUILayout.BeginHorizontal(horizontalStyle);

            GUIStyle iconStyle = new GUIStyle();

            iconStyle.padding      = new RectOffset(0, 0, 2, 2);
            iconStyle.margin       = new RectOffset(0, 0, 0, 0);
            iconStyle.border       = new RectOffset(0, 0, 0, 0);
            iconStyle.stretchWidth = false;


            // indent column
            GUILayout.Space(System.Math.Max(0, layer.indentLevel) * pixelsPerIndent);


            // type column
            GUIContent typeContent = new GUIContent();

            if (spriteLayer.hasSprite)
            {
                if (layer.isVisible)
                {
                    typeContent.image   = layout.editorGraphics.spriteLayerSprite;
                    typeContent.tooltip = "This is a sprite!";
                }
                else
                {
                    typeContent.image   = layout.editorGraphics.spriteLayerInvisible;
                    typeContent.tooltip = "A sprite with a disabled renderer.";
                }
            }
            else
            {
                if (deadLeaf)
                {
                    typeContent.image   = layout.editorGraphics.spriteLayerDeadLeaf;
                    typeContent.tooltip = "This dead-end layer will not be created.";
                }
                else
                {
                    typeContent.image   = layout.editorGraphics.spriteLayerFolder;
                    typeContent.tooltip = "This is a group.";
                }
            }
            GUILayout.Label(typeContent, iconStyle);

            // name column
            GUIContent nameContent = new GUIContent();

            nameContent.text = layout.GetBestName(layer);
            GUIStyle nameStyle = new GUIStyle(EditorStyles.label);

            nameStyle.stretchWidth = true;
            GUILayout.Label(nameContent, nameStyle);

            // assemble column
            if (!deadLeaf)
            {
                GUIContent assembleButtonContent = new GUIContent();
                assembleButtonContent.image = layout.editorGraphics.usain;
                if (spriteLayer.hasChildren)
                {
                    assembleButtonContent.tooltip = "Assemble this layer and children.";
                }
                else
                {
                    assembleButtonContent.tooltip = "Assemble this single sprite.";
                }


                GUIStyle assembleButtonStyle = new GUIStyle(EditorStyles.miniButton);
                assembleButtonStyle.stretchWidth = false;
                if (GUILayout.Button(assembleButtonContent, assembleButtonStyle))
                {
                    layout.startingLayer = layer;
#if PS2D_TK2D
                    SpriteCreator.CreateSprites(layout, layer, _spriteCollectionData);
#else
                    SpriteCreator.CreateSprites(layout, layer);
#endif
                }
            }

            GUILayout.EndVertical();
            GUILayout.EndHorizontal();
        }