예제 #1
0
        public virtual void DrawCurve()
        {
            if (transformMonitor != null)
            {
                transformMonitor.Check();
            }

            var settings = BGPrivateField.GetSettings(Math.Curve);

            BGEditorUtility.SwapGizmosColor(settings.LineColor, () =>
            {
                //========================================  Draw section
                for (var i = 0; i < Math.SectionsCount; i++)
                {
                    DrawSection(Math[i]);
                }
            });


            //========================================  Draw spheres
            if (settings.ShowSpheres)
            {
                BGEditorUtility.SwapGizmosColor(settings.SphereColor, () =>
                {
                    BeforeDrawingSpheres(settings);
                    for (var i = 0; i < Math.Curve.PointsCount; i++)
                    {
                        DrawSphere(settings, Math.GetPosition(i), settings.SphereRadius);
                    }
                    AfterDrawingSpheres();
                });
            }
        }
예제 #2
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();
        }