Exemple #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();
        }
Exemple #2
0
        private static void ShowPath(int index)
        {
            Path pathToShow = curcuitEditor.TargetCurcuit[index];

            bool isSelected = curcuitEditor.SelectedPath == pathToShow;

            GUIStyle foldoutStyle = new GUIStyle(EditorStyles.foldout);

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

            GUILayout.BeginHorizontal();

            pathToShow.isExpanded = EditorGUILayout.Foldout(pathToShow.isExpanded, $"Path {index}", true, foldoutStyle);

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

            GUILayout.EndHorizontal();

            if (pathToShow.isExpanded)
            {
                EditorGUI.indentLevel += 1;

                pathToShow.IsCyclic = EditorGUILayout.Toggle(
                    "Is path cyclic: ",
                    pathToShow.IsCyclic);

                EditorGUILayout.Space();

                ShowPoints(pathToShow);

                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();

                if (GUILayout.Button("Add new point",
                                     GUILayout.Height(25f), GUILayout.Width(200f)))
                {
                    curcuitEditor.AddPointInOrigin(index);
                    return;
                }

                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();


                EditorGUI.BeginDisabledGroup(curcuitEditor.SelectedSegment == new Vector2Int(-1, -1));
                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();

                if (GUILayout.Button("Insert point into selected curve",
                                     GUILayout.Height(25f), GUILayout.Width(200f)))
                {
                    curcuitEditor.InsertPoint();
                    return;
                }

                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();
                EditorGUI.EndDisabledGroup();

                EditorGUI.indentLevel -= 1;
            }
        }