Пример #1
0
        private void OnEditorUpdate()
        {
            InspectableState viewOptionsState = guiViewSettings.Refresh();

            if (viewOptionsState != InspectableState.NotModified)
            {
                SceneWindow sceneWindow = SceneWindow.GetWindow <SceneWindow>();
                if (sceneWindow != null)
                {
                    sceneWindow.Camera.ViewSettings = viewSettings;
                }

                ProjectSettings.SetObject(SceneCamera.ViewSettingsKey, viewSettings);
            }

            InspectableState moveOptionsState = guiMovementSettings.Refresh();

            if (moveOptionsState != InspectableState.NotModified)
            {
                SceneWindow sceneWindow = SceneWindow.GetWindow <SceneWindow>();
                if (sceneWindow != null)
                {
                    sceneWindow.Camera.MoveSettings = moveSettings;
                }

                ProjectSettings.SetObject(SceneCamera.MoveSettingsKey, moveSettings);
            }

            InspectableState renderOptionsState = guiRenderSettings.Refresh();

            if (renderOptionsState != InspectableState.NotModified)
            {
                SceneWindow sceneWindow = SceneWindow.GetWindow <SceneWindow>();
                if (sceneWindow != null)
                {
                    sceneWindow.Camera.RenderSettings = renderSettings;
                }

                ProjectSettings.SetObject(SceneCamera.RenderSettingsKey, renderSettings);
            }

            InspectableState gizmoOptionsState = guiGizmoSettings.Refresh();

            if (gizmoOptionsState != InspectableState.NotModified)
            {
                gizmoSettings = (GizmoDrawSettings)objGizmoSettings;

                SceneWindow sceneWindow = SceneWindow.GetWindow <SceneWindow>();
                if (sceneWindow != null)
                {
                    sceneWindow.GizmoDrawSettings = gizmoSettings;
                }

                ProjectSettings.SetObject(SceneWindow.GizmoDrawSettingsKey, gizmoSettings);
            }
        }
        /// <summary>Initializes the struct with default values.</summary>
        public static GizmoDrawSettings Default()
        {
            GizmoDrawSettings value = new GizmoDrawSettings();

            value.iconScale    = 1f;
            value.iconRange    = 500f;
            value.iconSizeMin  = 0.0500000007f;
            value.iconSizeMax  = 0.150000006f;
            value.iconSizeCull = 0.25f;

            return(value);
        }
Пример #3
0
        /// <summary>
        /// Resets all scene camera settings to default values.
        /// </summary>
        private void ResetToDefault()
        {
            viewSettings   = new SceneCameraViewSettings();
            moveSettings   = new SceneCameraMoveSettings();
            renderSettings = new RenderSettings();
            gizmoSettings  = GizmoDrawSettings.Default();

            SceneWindow sceneWindow = SceneWindow.GetWindow <SceneWindow>();

            if (sceneWindow != null)
            {
                sceneWindow.Camera.ViewSettings   = viewSettings;
                sceneWindow.Camera.MoveSettings   = moveSettings;
                sceneWindow.Camera.RenderSettings = renderSettings;
                sceneWindow.GizmoDrawSettings     = gizmoSettings;
            }

            ProjectSettings.SetObject(SceneCamera.ViewSettingsKey, viewSettings);
            ProjectSettings.SetObject(SceneCamera.MoveSettingsKey, moveSettings);
            ProjectSettings.SetObject(SceneCamera.RenderSettingsKey, renderSettings);
            ProjectSettings.SetObject(SceneWindow.GizmoDrawSettingsKey, gizmoSettings);
        }
Пример #4
0
        private void OnInitialize()
        {
            EditorApplication.OnProjectSave += SaveSettings;

            SceneWindow sceneWindow = SceneWindow.GetWindow <SceneWindow>();

            if (sceneWindow != null)
            {
                viewSettings   = sceneWindow.Camera.ViewSettings;
                moveSettings   = sceneWindow.Camera.MoveSettings;
                renderSettings = sceneWindow.Camera.RenderSettings;
                gizmoSettings  = sceneWindow.GizmoDrawSettings;
            }
            else
            {
                viewSettings   = ProjectSettings.GetObject <SceneCameraViewSettings>(SceneCamera.ViewSettingsKey);
                moveSettings   = ProjectSettings.GetObject <SceneCameraMoveSettings>(SceneCamera.MoveSettingsKey);
                renderSettings = ProjectSettings.GetObject <RenderSettings>(SceneCamera.RenderSettingsKey);

                if (ProjectSettings.HasKey(SceneWindow.GizmoDrawSettingsKey))
                {
                    gizmoSettings = ProjectSettings.GetObject <GizmoDrawSettings>(SceneWindow.GizmoDrawSettingsKey);
                }
                else
                {
                    gizmoSettings = GizmoDrawSettings.Default();
                }
            }

            expandStates = ProjectSettings.GetObject <SerializableProperties>(ExpandStatesKey);
            InspectableContext inspectableContext = new InspectableContext(expandStates);

            GUILayout mainLayout = GUI.AddLayoutY();

            GUIScrollArea scrollArea = new GUIScrollArea(ScrollBarType.ShowIfDoesntFit, ScrollBarType.NeverShow);

            mainLayout.AddElement(scrollArea);

            GUILayoutX horzPadLayout = scrollArea.Layout.AddLayoutX(GUIOption.FlexibleWidth(100, 400));

            horzPadLayout.AddSpace(5);

            GUILayout vertLayout = horzPadLayout.AddLayoutY();

            horzPadLayout.AddSpace(5);

            vertLayout.AddSpace(5);

            vertLayout.AddElement(new GUILabel(new LocEdString("View Settings"), EditorStyles.LabelBold));
            GUILayoutY viewSettingsLayout = vertLayout.AddLayoutY();

            vertLayout.AddSpace(10);

            vertLayout.AddElement(new GUILabel(new LocEdString("Gizmo Settings"), EditorStyles.LabelBold));
            GUILayoutY gizmoSettingsLayout = vertLayout.AddLayoutY();

            vertLayout.AddSpace(10);

            vertLayout.AddElement(new GUILabel(new LocEdString("Move Settings"), EditorStyles.LabelBold));
            GUILayoutY moveSettingsLayout = vertLayout.AddLayoutY();

            vertLayout.AddSpace(10);

            vertLayout.AddElement(new GUILabel(new LocEdString("Render Settings"), EditorStyles.LabelBold));
            GUILayoutY renderSettingsLayout = vertLayout.AddLayoutY();

            guiViewSettings     = new InspectorFieldDrawer(inspectableContext, viewSettingsLayout);
            guiGizmoSettings    = new InspectorFieldDrawer(inspectableContext, gizmoSettingsLayout);
            guiMovementSettings = new InspectorFieldDrawer(inspectableContext, moveSettingsLayout);
            guiRenderSettings   = new InspectorFieldDrawer(inspectableContext, renderSettingsLayout);

            objGizmoSettings = gizmoSettings;

            guiViewSettings.AddDefault(viewSettings);
            guiGizmoSettings.AddDefault(objGizmoSettings);
            guiMovementSettings.AddDefault(moveSettings);
            guiRenderSettings.AddDefault(renderSettings);

            mainLayout.AddSpace(5);
            GUILayout buttonCenterLayout = mainLayout.AddLayoutX();

            mainLayout.AddSpace(5);

            GUIButton resetToDefaultBtn = new GUIButton(new LocEdString("Reset to defaults"));

            resetToDefaultBtn.OnClick += () => ConfirmResetToDefault(ResetToDefault, null);

            buttonCenterLayout.AddFlexibleSpace();
            buttonCenterLayout.AddElement(resetToDefaultBtn);
            buttonCenterLayout.AddFlexibleSpace();
        }
Пример #5
0
 private static extern void Internal_GetDrawSettings(IntPtr thisPtr, out GizmoDrawSettings settings);
Пример #6
0
 private static extern void Internal_Create(SceneGizmos managedInstance, IntPtr camera,
                                            ref GizmoDrawSettings drawSettings);
Пример #7
0
 /// <summary>
 /// Creates a new scene gizmo renderer.
 /// </summary>
 /// <param name="sceneCamera">Camera into which the gizmos will be rendered.</param>
 /// <param name="drawSettings">Settings that control how are gizmos drawn.</param>
 internal SceneGizmos(Camera sceneCamera, GizmoDrawSettings drawSettings)
 {
     Internal_Create(this, sceneCamera.GetCachedPtr(), ref drawSettings);
 }
Пример #8
0
 /// <summary>
 /// Creates a new scene selection manager.
 /// </summary>
 /// <param name="sceneCamera">Camera into which to render the selection overlay, and perform picking from.</param>
 /// <param name="drawSettings">Settings that control how are pickable gizmos drawn.</param>
 internal SceneSelection(Camera sceneCamera, GizmoDrawSettings gizmoDrawSettings)
 {
     Internal_Create(this, sceneCamera.GetCachedPtr(), ref gizmoDrawSettings);
 }
Пример #9
0
 private static extern void Internal_SetGizmoDrawSettings(IntPtr thisPtr, ref GizmoDrawSettings settings);
Пример #10
0
 private static extern void Internal_Create(SceneSelection managedInstance, IntPtr camera, ref GizmoDrawSettings gizmoDrawSettings);