Esempio n. 1
0
 void OnSelectModeChanged(SelectMode selectMode)
 {
     if (ToolManager.IsActiveTool(this) && selectMode != SelectMode.Object)
     {
         ToolManager.RestorePreviousTool();
     }
 }
Esempio n. 2
0
        protected void DoEditButton <U>(GUIContent icon, string label) where U : PathEditorTool <T>
        {
            const float kButtonWidth  = 33;
            const float kButtonHeight = 23;
            const float k_SpaceBetweenLabelAndButton = 5;
            var         buttonStyle = new GUIStyle("EditModeSingleButton");

            var rect       = EditorGUILayout.GetControlRect(true, kButtonHeight, buttonStyle);
            var buttonRect = new Rect(rect.xMin + EditorGUIUtility.labelWidth, rect.yMin, kButtonWidth, kButtonHeight);

            var labelContent = new GUIContent(label);
            var labelSize    = GUI.skin.label.CalcSize(labelContent);

            var labelRect = new Rect(
                buttonRect.xMax + k_SpaceBetweenLabelAndButton,
                rect.yMin + (rect.height - labelSize.y) * .5f,
                labelSize.x,
                rect.height);

            using (new EditorGUI.DisabledGroupScope(!EditorToolManager.IsAvailable <U>()))
            {
                using (var check = new EditorGUI.ChangeCheckScope())
                {
                    var isActive = GUI.Toggle(buttonRect, EditorToolManager.IsActiveTool <U>(), icon, buttonStyle);

                    GUI.Label(labelRect, label);

                    if (check.changed)
                    {
                        if (isActive)
                        {
                            ToolManager.SetActiveTool <U>();
                        }
                        else
                        {
                            ToolManager.RestorePreviousTool();
                        }
                    }
                }
            }
        }