コード例 #1
0
ファイル: BGCurveEditor.cs プロジェクト: MAtaur00/IA_Handouts
        public override void OnInspectorGUI()
        {
            //adjust math if needed
            AdjustMath(BGPrivateField.GetSettings(Curve), Math);

            //styles
            BGEditorUtility.Assign(ref stickerStyle, () => new GUIStyle("Label") {fontSize = 18, alignment = TextAnchor.MiddleCenter, normal = new GUIStyleState {textColor = Color.white}});

            serializedObject.Update();

            // =========== Header
            DrawLogo();

            // =========== lock view
            BGEditorUtility.Horizontal(() =>
            {
                var temp = BGCurveSettingsForEditor.LockView;
                BGCurveSettingsForEditor.LockView = BGEditorUtility.ButtonOnOff(ref temp, "Lock view", "Disable selection of any object in the scene, except points", LockViewActiveColor,
                    new GUIContent("Turn Off", "Click to turn this mode off"),
                    new GUIContent("Turn On", "Click to turn this mode on"));

                if (GUILayout.Button(BGBinaryResources.BGSettingsIcon123, GUILayout.MaxWidth(24), GUILayout.MaxHeight(24))) BGCurveSettingsForEditorWindow.Open(BGCurveSettingsForEditor.I);
            });

            //warning
            BGEditorUtility.HelpBox("You can not chose another objects in the scene, except points.", MessageType.Warning, BGCurveSettingsForEditor.LockView, () => GUILayout.Space(8));

            // =========== Tabs
            var currentTab = BGCurveSettingsForEditor.CurrentTab;
            if (currentTab < 0 || currentTab > headers.Length - 1) currentTab = 0;
            var newTab = GUILayout.Toolbar(currentTab, headers, GUILayout.Height(ToolBarHeight));
            //do not move this method(GUILayoutUtility.GetLastRect() is used) 
            ShowStickers();
            if (currentTab != newTab) GUI.FocusControl("");
            BGCurveSettingsForEditor.CurrentTab = newTab;
            editors[newTab].OnInspectorGui();

            if (!GUI.changed) return; // if no change- return

            foreach (var editor in editors) editor.OnApply();

            transformMonitor.CheckForChange();
        }
コード例 #2
0
        // ================================================================================ Inspector
        public override void OnInspectorGui()
        {
            var settings = Settings;

            editorSelection.Reset();

            // ======================================== Top section
            InspectorTopSection();

            // ======================================== Points
            GUILayout.Space(5);

            if (Curve.PointsCount > 0)
            {
                BGEditorUtility.VerticalBox(() =>
                {
                    var temp = BGCurveSettingsForEditor.DisableInspectorPointMenu;
                    BGCurveSettingsForEditor.DisableInspectorPointMenu = BGEditorUtility.ButtonOnOff(ref temp, "Points menu [" + Curve.PointsCount + "]", "Show points in Editor inspector",
                                                                                                     HiddenPointMenuColor,
                                                                                                     new GUIContent("Show", "Click to show points menu"),
                                                                                                     new GUIContent("Hide", "Click to hide points menu"), () =>
                    {
                        const string title = "Reverse points";

                        if (!GUILayout.Button(new GUIContent(title, "Reverse all points, but keep curve intact")))
                        {
                            return;
                        }

                        if (Curve.PointsCount < 2)
                        {
                            BGEditorUtility.Inform(title, "There should be at least 2 points. Curve has " + Curve.PointsCount);
                            return;
                        }
                        if (!BGEditorUtility.Confirm(title, "Are you sure you want to reverse the order of " + Curve.PointsCount + " points? Curve will remain intact.", "Reverse"))
                        {
                            return;
                        }

                        Curve.Reverse();
                    });

                    //show points!
                    if (!BGCurveSettingsForEditor.DisableInspectorPointMenu)
                    {
                        SwapVector2Labels(Curve.Mode2D, () => Curve.ForEach((point, index, count) => editorPoint.OnInspectorGui(point, index, settings)));
                    }
                });

                // ======================================== Selections operations
                editorSelection.InspectorSelectionOperations();

                //warning
                BGEditorUtility.HelpBox("Selection mode is on", MessageType.Warning, !editorSelection.Changed && editorSelection.HasSelected());
            }
            else
            {
                BGEditorUtility.HorizontalBox(() =>
                {
                    EditorGUILayout.LabelField("No points!");

                    if (BGEditorUtility.ButtonWithIcon(BGBinaryResources.BGAdd123, "Add new point at (0,0,0) local coordinates"))
                    {
                        BGCurveEditor.AddPoint(Curve, new BGCurvePoint(Curve, Vector3.zero, settings.ControlType, Vector3.right, Vector3.left), 0);
                    }
                });
            }

            if (!editorSelection.Changed)
            {
                return;
            }

            Editor.Repaint();
            SceneView.RepaintAll();
        }
コード例 #3
0
        public override void OnInspectorGUI()
        {
            //adjust math if needed
            AdjustMath(BGPrivateField.GetSettings(Curve), Math);

            //styles
            BGEditorUtility.Assign(ref stickerStyle, () => new GUIStyle("Label")
            {
                fontSize = 18, alignment = TextAnchor.MiddleCenter, normal = new GUIStyleState {
                    textColor = Color.white
                }
            });
            BGEditorUtility.Assign(ref settingsTexture, () => BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGSettingsIcon123));

            serializedObject.Update();

            // =========== Header
            DrawLogo();

            // =========== lock view
            BGEditorUtility.Horizontal(() =>
            {
                var temp = BGCurveSettingsForEditor.LockView;
                BGCurveSettingsForEditor.LockView = BGEditorUtility.ButtonOnOff(ref temp, "Lock view", "Disable selection of other objects in the scene", LockViewActiveColor,
                                                                                new GUIContent("Turn Off", "Click to turn this mode off"),
                                                                                new GUIContent("Turn On", "Click to turn this mode on"));

                if (BGEditorUtility.ButtonWithIcon(settingsTexture, "Open BGCurve Editor Settings", 24, 24))
                {
                    BGCurveSettingsForEditorWindow.Open();
                }
            });

            //warning
            BGEditorUtility.HelpBox("You can not chose another objects in the scene, except points.\r\n Use rectangular selection without pressing shift", MessageType.Warning,
                                    BGCurveSettingsForEditor.LockView, () => GUILayout.Space(8));

            // =========== Tabs
            if (BGCurveSettingsForEditor.CurrentTab < 0 || BGCurveSettingsForEditor.CurrentTab > headers.Length - 1)
            {
                BGCurveSettingsForEditor.CurrentTab = 0;
            }
            BGCurveSettingsForEditor.CurrentTab = GUILayout.Toolbar(BGCurveSettingsForEditor.CurrentTab, headers, GUILayout.Height(ToolBarHeight));
            //do not move this method(GUILayoutUtility.GetLastRect() is used)
            ShowStickers();
            editors[BGCurveSettingsForEditor.CurrentTab].OnInspectorGui();


            if (!GUI.changed)
            {
                return;               // if no change- return
            }
            foreach (var editor in editors)
            {
                editor.OnBeforeApply();
            }

            serializedObject.ApplyModifiedProperties();
            EditorUtility.SetDirty(Curve);

            foreach (var editor in editors)
            {
                editor.OnApply();
            }

            transformMonitor.Check();
        }