private STEditorToolbars() { List <GUIContent> guiContentList = new List <GUIContent>() { new GUIContent(ToolIcons.GetToolTexture(ToolIcons.eToolIcon.Pencil), "Paint"), new GUIContent(ToolIcons.GetToolTexture(ToolIcons.eToolIcon.Erase), "Erase (Hold Shift)"), new GUIContent(ToolIcons.GetToolTexture(ToolIcons.eToolIcon.Fill), "Fill (Double click)"), new GUIContent(ToolIcons.GetToolTexture(ToolIcons.eToolIcon.FlipH), "Flip Horizontal (" + ShortcutKeys.k_FlipH + ")"), new GUIContent(ToolIcons.GetToolTexture(ToolIcons.eToolIcon.FlipV), "Flip Vertical (" + ShortcutKeys.k_FlipV + ")"), new GUIContent(ToolIcons.GetToolTexture(ToolIcons.eToolIcon.Rot90), "Rotate 90 clockwise (" + ShortcutKeys.k_Rot90 + "); anticlockwise (" + ShortcutKeys.k_Rot90Back + ")"), new GUIContent(ToolIcons.GetToolTexture(ToolIcons.eToolIcon.Info), " Display Help (F1)"), new GUIContent(ToolIcons.GetToolTexture(ToolIcons.eToolIcon.Refresh), " Refresh Tilemap (F5)"), }; brushToolbar = new ToolbarControl(guiContentList); brushToolbar.OnToolSelected += OnToolSelected_BrushToolbar; guiContentList = new List <GUIContent>() { new GUIContent(ToolIcons.GetToolTexture(ToolIcons.ePaintModeIcon.Pencil), "Paint (" + ShortcutKeys.k_PencilTool + ")"), new GUIContent(ToolIcons.GetToolTexture(ToolIcons.ePaintModeIcon.Line), "Line (" + ShortcutKeys.k_LineTool + ")"), new GUIContent(ToolIcons.GetToolTexture(ToolIcons.ePaintModeIcon.Rect), "Rectangle (" + ShortcutKeys.k_RectTool + ")"), new GUIContent(ToolIcons.GetToolTexture(ToolIcons.ePaintModeIcon.FilledRect), "Filled Rectangle (" + ShortcutKeys.k_RectTool + ")"), new GUIContent(ToolIcons.GetToolTexture(ToolIcons.ePaintModeIcon.Ellipse), "Ellipse (" + ShortcutKeys.k_EllipseTool + ")"), new GUIContent(ToolIcons.GetToolTexture(ToolIcons.ePaintModeIcon.FilledEllipse), "Filled Ellipse (" + ShortcutKeys.k_EllipseTool + ")"), }; brushPaintToolbar = new ToolbarControl(guiContentList); brushPaintToolbar.OnToolSelected += OnToolSelected_BrushPaintToolbar; }
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)); }