示例#1
0
        protected void DoOpenEndedInspector <U>(SerializedProperty isOpenEndedProperty) where U : PathEditorTool <T>
        {
            serializedObject.Update();

            using (var check = new EditorGUI.ChangeCheckScope())
            {
                EditorGUILayout.PropertyField(isOpenEndedProperty);

                if (check.changed)
                {
                    if (EditorToolManager.IsActiveTool <U>() && EditorToolManager.IsAvailable <U>())
                    {
                        var paths = EditorToolManager.GetEditorTool <U>().paths;

                        foreach (var path in paths)
                        {
                            path.undoObject.RegisterUndo("Set Open Ended");
                            path.isOpenEnded = isOpenEndedProperty.boolValue;
                        }
                    }
                }
            }

            serializedObject.ApplyModifiedProperties();
        }
示例#2
0
        private void OnDestroy()
        {
            EditorToolManager.Remove(this);

            ToolManager.activeToolChanged -= HandleActivation;
            UnregisterCallbacks();
        }
示例#3
0
 protected void DoSnappingInspector <U>() where U : PathEditorTool <T>
 {
     if (EditorToolManager.IsActiveTool <U>() && EditorToolManager.IsAvailable <U>())
     {
         var tool = EditorToolManager.GetEditorTool <U>();
         tool.enableSnapping = EditorGUILayout.Toggle(Contents.snappingLabel, tool.enableSnapping);
     }
 }
示例#4
0
        private void OnEnable()
        {
            m_IsActive = false;
            EditorToolManager.Add(this);

            SetupRectSelector();
            HandleActivation();

            ToolManager.activeToolChanged += HandleActivation;
        }
示例#5
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)
                        {
                            EditorTools.EditorTools.SetActiveTool <U>();
                        }
                        else
                        {
                            EditorTools.EditorTools.RestorePreviousTool();
                        }
                    }
                }
            }
        }
示例#6
0
        protected void DoPathInspector <U>() where U : PathEditorTool <T>
        {
            if (EditorToolManager.IsActiveTool <U>() && EditorToolManager.IsAvailable <U>())
            {
                var paths = EditorToolManager.GetEditorTool <U>().paths;

                CreateCachedEditor(paths, null, ref m_CachedEditor);

                if (m_CachedEditor == null) //Needed to avoid a nullref on exiting playmode
                {
                    return;
                }

                using (var check = new EditorGUI.ChangeCheckScope())
                {
                    m_CachedEditor.OnInspectorGUI();

                    if (check.changed)
                    {
                        EditorToolManager.GetEditorTool <U>().SetShapes();
                    }
                }
            }
        }