Example #1
0
 public static void SFlipH()
 {
     if (s_instance)
     {
         s_instance.FlipH();
     }
 }
Example #2
0
        private void _DoToolbarButton(Rect rToolBtn, ToolIcons.eToolIcon toolIcon)
        {
            BrushBehaviour brush        = BrushBehaviour.GetOrCreateBrush((Tilemap)target);
            int            iconPadding  = 6;
            Rect           rToolIcon    = new Rect(rToolBtn.x + iconPadding, rToolBtn.y + iconPadding, rToolBtn.size.y - 2 * iconPadding, rToolBtn.size.y - 2 * iconPadding);
            Color          activeColor  = new Color(1f, 1f, 1f, 0.8f);
            Color          disableColor = new Color(1f, 1f, 1f, 0.4f);

            switch (toolIcon)
            {
            case ToolIcons.eToolIcon.Pencil:
                GUI.color = GetBrushMode() == eBrushMode.Paint ? activeColor : disableColor;
                if (GUI.Button(rToolBtn, new GUIContent("", "Paint")))
                {
                    s_brushMode = eBrushMode.Paint;
                }
                break;

            case ToolIcons.eToolIcon.Erase:
                GUI.color = GetBrushMode() == eBrushMode.Erase ? activeColor : disableColor;
                if (GUI.Button(rToolBtn, new GUIContent("", "Erase (Hold Shift)")))
                {
                    s_brushMode = eBrushMode.Erase;
                }
                break;

            case ToolIcons.eToolIcon.Fill:
                GUI.color = GetBrushMode() == eBrushMode.Fill ? activeColor : disableColor;
                if (GUI.Button(rToolBtn, new GUIContent("", "Fill (Double click)")))
                {
                    s_brushMode = eBrushMode.Fill;
                }
                break;

            case ToolIcons.eToolIcon.FlipV:
                GUI.color = s_brushFlipV ? activeColor : disableColor;
                if (GUI.Button(rToolBtn, new GUIContent("", "Flip Vertical (" + ShortcutKeys.k_FlipV + ")")))
                {
                    brush.FlipV();
                    s_brushFlipV = !s_brushFlipV;
                }
                break;

            case ToolIcons.eToolIcon.FlipH:
                GUI.color = s_brushFlipH ? activeColor : disableColor;
                if (GUI.Button(rToolBtn, new GUIContent("", "Flip Horizontal (" + ShortcutKeys.k_FlipH + ")")))
                {
                    brush.FlipH();
                    s_brushFlipH = !s_brushFlipH;
                }
                break;

            case ToolIcons.eToolIcon.Rot90:
                GUI.color = s_brushRot90 ? activeColor : disableColor;
                if (GUI.Button(rToolBtn, new GUIContent("", "Rotate 90 clockwise (" + ShortcutKeys.k_Rot90 + "); anticlockwise (" + ShortcutKeys.k_Rot90Back + ")")))
                {
                    if (!s_brushRot90)
                    {
                        brush.Rot90();
                    }
                    else
                    {
                        brush.Rot90Back();
                    }
                    s_brushRot90 = !s_brushRot90;
                }
                break;

            case ToolIcons.eToolIcon.Info:
                GUI.color = m_displayHelpBox ? activeColor : disableColor;
                if (GUI.Button(rToolBtn, new GUIContent("", " Display Help (F1)")))
                {
                    m_displayHelpBox = !m_displayHelpBox;
                }
                break;

            case ToolIcons.eToolIcon.Refresh:
                GUI.color = m_displayHelpBox ? activeColor : disableColor;
                if (GUI.Button(rToolBtn, new GUIContent("", " Refresh Tilemap (F5)")))
                {
                    TilemapGroup tilemapGroup = Selection.activeGameObject.GetComponent <TilemapGroup>();
                    if (tilemapGroup)
                    {
                        foreach (Tilemap tilemap in tilemapGroup.Tilemaps)
                        {
                            tilemap.Refresh(true, true, true, true);
                        }
                    }
                    else
                    {
                        m_tilemap.Refresh(true, true, true, true);
                    }
                }
                break;
            }
            GUI.color = Color.white;
            GUI.DrawTexture(rToolIcon, ToolIcons.GetToolTexture(toolIcon));
        }