예제 #1
0
        private static void ShowRemoveGenericMenu()
        {
            GenericMenu removeMenu = new GenericMenu();

            if (curcuitEditor.SelectedPath != null && curcuitEditor.TargetCurcuit.Count > 1)
            {
                removeMenu.AddItem(new GUIContent("Remove selected path"), false,
                                   () =>
                {
                    curcuitEditor.RemovePath();
                });
            }
            else
            {
                removeMenu.AddDisabledItem(new GUIContent("Remove selected path"));
            }

            if (curcuitEditor.SelectedBezierPoint != null && curcuitEditor.SelectedPath.Count > 1)
            {
                removeMenu.AddItem(new GUIContent("Remove selected point"), false,
                                   () =>
                {
                    curcuitEditor.RemovePoint();
                });
            }
            else
            {
                removeMenu.AddDisabledItem(new GUIContent("Remove selected point"));
            }

            removeMenu.ShowAsContext();
        }
예제 #2
0
        private static void ShowPoint(Path path, int index)
        {
            bool isSelected = curcuitEditor.SelectedBezierPoint == path[index];

            GUIStyle foldoutStyle = new GUIStyle(EditorStyles.foldout);

            if (isSelected)
            {
                foldoutStyle.fontStyle          = FontStyle.Bold;
                foldoutStyle.normal.textColor   = curcuitEditor.SelectedBezierPointInspectorColor;
                foldoutStyle.onNormal.textColor = curcuitEditor.SelectedBezierPointInspectorColor;
            }

            EditorGUILayout.BeginHorizontal();

            path[index].isExpanded
                = EditorGUILayout.Foldout(path[index].isExpanded, $"Bezier point {index}", true, foldoutStyle);

            if (GUILayout.Button("X", new GUIStyle(EditorStyles.miniButton)
            {
            }, GUILayout.Height(20f), GUILayout.Width(20f)))
            {
                curcuitEditor.RemovePoint(path, index);
                return;
            }

            EditorGUILayout.EndHorizontal();

            if (path[index].isExpanded)
            {
                EditorGUI.indentLevel += 1;

                path[index].ControlPointMode
                    = (BezierControlPointMode)EditorGUILayout.EnumPopup("Control point mode", path[index].ControlPointMode);

                path[index].Anchor
                    = EditorGUILayout.Vector2Field("Anchor point", path[index].Anchor);
                path[index].ControlPoint1
                    = EditorGUILayout.Vector2Field("Control point 1", path[index].ControlPoint1);
                path[index].ControlPoint2
                    = EditorGUILayout.Vector2Field("Control point 2", path[index].ControlPoint2);

                EditorGUI.indentLevel -= 1;
            }
        }