Esempio n. 1
0
        private void DoToolSceneGUI(ToolBase tool)
        {
            var tileSystem = target as TileSystem;

            // Toggle preview material using control key.
            this.CheckSwitchImmediatePreviewMaterial();

            ToolUtility.CheckToolKeyboardShortcuts();

            // Preserve current state of handles.
            Matrix4x4 originalMatrix     = Handles.matrix;
            Color     restoreHandleColor = Handles.color;

            // Place handles within local space of tile system.
            Handles.matrix = tileSystem.transform.localToWorldMatrix;

            // Tools cannot interact with locked tile systems!
            if (!tileSystem.Locked)
            {
                tool.OnSceneGUI(this.toolEvent, this);
            }
            else
            {
                Vector3 activeCenter = Vector3.zero;
                activeCenter.x += this.toolEvent.MousePointerTileIndex.column * tileSystem.CellSize.x + tileSystem.CellSize.x / 2f;
                activeCenter.y -= this.toolEvent.MousePointerTileIndex.row * tileSystem.CellSize.y + tileSystem.CellSize.y / 2f;

                ToolHandleUtility.DrawWireBox(activeCenter, tileSystem.CellSize);
            }

            // Restore former state of handles.
            Handles.matrix = originalMatrix;
            Handles.color  = restoreHandleColor;
        }
        private void OnKeyboardGUI()
        {
            int controlID = GUIUtility.GetControlID(FocusType.Keyboard);

            if (Event.current.GetTypeForControl(controlID) != EventType.KeyDown)
            {
                return;
            }

            if (GUIUtility.keyboardControl == 0)
            {
                ToolManager.Instance.CheckForKeyboardShortcut();
                ToolUtility.CheckToolKeyboardShortcuts();
            }
        }
        internal void DrawBrushesGUI()
        {
            this.DrawToolbar();

            if (GUIUtility.keyboardControl == 0)
            {
                ToolManager.Instance.CheckForKeyboardShortcut();
                ToolUtility.CheckToolKeyboardShortcuts();
            }

            GUILayout.Space(-1);

            // Is selected brush (primary or secondary) about to be changed?
            this.brushList.Draw(false);

            this.DrawPrimarySecondaryBrushSwitcher();

            GUILayout.Space(5);
        }
        /// <inheritdoc/>
        protected override void DoGUI()
        {
            // Generate a control ID for the palette window so that keyboard focus can be
            // easily removed from the active control.
            int paletteControlID = EditorGUIUtility.GetControlID(FocusType.Keyboard);

            if (this.clearInputFocus || Event.current.type == EventType.MouseDown || Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Escape)
            {
                this.clearInputFocus             = false;
                EditorGUIUtility.keyboardControl = paletteControlID;
                this.Repaint();
            }

            if (GUIUtility.keyboardControl == paletteControlID)
            {
                ToolManager.Instance.CheckForKeyboardShortcut();
                ToolUtility.CheckToolKeyboardShortcuts();
            }

            this.OnToolSelectorGUI();

            RotorzEditorGUI.DrawHoverTip(this);
        }