Exemple #1
0
        void OnEnable()
        {
            t = target as GDOC;

            labelStyle          = new GUIStyle();
            labelStyle.wordWrap = true;
            labelStyle.padding  = new RectOffset(2, 2, 2, 2);

            swStyle            = new GUIStyle();
            swStyle.padding    = new RectOffset(10, 10, 10, 10);
            swStyle.fixedWidth = 0;

            foldoutButtonStyle           = new GUIStyle();
            foldoutButtonStyle.fontStyle = FontStyle.Bold;
            foldoutButtonStyle.padding   = new RectOffset(2, 2, 8, 6);

            moduleHeaderStyle = new GUIStyle();
        }
Exemple #2
0
        public override void OnInspectorGUI()
        {
            EditorGUIUtility.labelWidth = 150;

            if (!Application.isPlaying)
            {
                foreach (var e in targets)
                {
                    (e as GDOC_Occludee).UpdateBounds();
                }
            }

            var t        = targets[0] as GDOC_Occludee;
            var isSingle = targets.Length == 1;

            EditorGUI.BeginChangeCheck();

            if (isSingle && t.runtimeId > -1)
            {
                EditorGUI.BeginDisabledGroup(true);
            }

            EditorGUI.BeginChangeCheck();
            FastPropertyField("mode", "Mode");

            if (EditorGUI.EndChangeCheck())
            {
                serializedObject.ApplyModifiedProperties();
                t.Init();
            }

            if (isSingle)
            {
                if (t.initError != GDOC_Error.None)
                {
                    EditorGUILayout.HelpBox("Init Error: " + t.initError, MessageType.Error);
                }
                else
                {
                    if (t.isExcluded)
                    {
                        FastPropertyField("withChildren", "With Children");
                    }
                    else
                    {
                        if (t.isMeshRenderer || t.isMeshRendererGroup)
                        {
                            FastPropertyField("managementMode", "Manage mode");
                        }

                        FastPropertyField("movementMode", "Update mode");

                        if (t.isRendererGroup)
                        {
                            GUILayout.Label("Manages " + t.managedRenderersCount + " renderers");

                            if (t.renderers != null && t.renderers.Count > 0)
                            {
                                for (var i = 0; i < t.renderers.Count; i++)
                                {
                                    GUILayout.Label((i + 1) + ": " + t.renderers[i].name);
                                }
                            }

                            if (t.noShadowRenderers != null && t.noShadowRenderers.Count > 0)
                            {
                                GUILayout.Label("No shadows");

                                for (var i = 0; i < t.noShadowRenderers.Count; i++)
                                {
                                    GUILayout.Label((i + 1) + ": " + t.noShadowRenderers[i].name);
                                }
                            }

                            if (t.shadowOnlyRenderers != null && t.shadowOnlyRenderers.Count > 0)
                            {
                                GUILayout.Label("Shadows only");

                                for (var i = 0; i < t.shadowOnlyRenderers.Count; i++)
                                {
                                    GUILayout.Label((i + 1) + ": " + t.shadowOnlyRenderers[i].name);
                                }
                            }

                            if (t.GetComponent <LODGroup>() == null)
                            {
                                EditorGUI.BeginDisabledGroup(true);
                            }

                            if (GUILayout.Button("Grab LODGroup renderers"))
                            {
                                t.GrabLODGroupRenderers();
                            }

                            if (t.GetComponent <LODGroup>() == null)
                            {
                                EditorGUI.EndDisabledGroup();
                            }

                            if (GUILayout.Button("Grab all child renderers"))
                            {
                                t.GrabAllChildRenderers();
                            }
                        }

                        if (t.hasCustomBounds)
                        {
                            FastPropertyField("center", "Center");
                            FastPropertyField("extents", "Extents");

                            if (GUILayout.Button("Encapsulate children"))
                            {
                                t.RecalculateContainerBounds();
                                SceneView.RepaintAll();
                            }
                        }
                        else
                        {
                            EditorGUI.BeginDisabledGroup(true);

                            EditorGUILayout.Vector3Field("Position", t.position);
                            EditorGUILayout.Vector3Field("Extents", t.size);

                            EditorGUI.EndDisabledGroup();
                        }

                        FastPropertyField("sizeMultiplier", "Size Multiplier");

                        otherSettings = EditorGUILayout.Foldout(otherSettings, "Other settings");

                        if (otherSettings)
                        {
                            if (t.isDynamic)
                            {
                                FastPropertyField("dynamicUpdateInterval", "Update Interval (sec)");
                            }

                            FastPropertyField("isImportant", "Is Important");
                            FastPropertyField("isShadowSource", "Is Shadow Source");
                            FastPropertyField("disablePrediction", "Disable Prediction");
                        }

                        if (t.runtimeId > -1)
                        {
                            EditorGUI.EndDisabledGroup();

                            EditorGUILayout.HelpBox(string.Format("Runtime ID: {0}\nState: {1}", t.runtimeId, t.currentState), MessageType.Info);

                            if (GUILayout.Button("Update"))
                            {
                                GDOC.UpdateOccludee(t);
                            }

                            if (GUILayout.Button("Disable"))
                            {
                                GDOC.RemoveOccludee(t);
                            }
                        }
                        else if (Application.isPlaying)
                        {
                            if (GUILayout.Button("Enable"))
                            {
                                GDOC.AddOccludee(t);
                            }
                        }
                    }
                }
            }
            else
            {
                FastPropertyField("movementMode", "Movement Mode");
                FastPropertyField("center", "Center");
                FastPropertyField("extents", "Extents");
                FastPropertyField("sizeMultiplier", "Size Multiplier");

                EditorGUILayout.HelpBox("Multi-editing of other settings is not supported.", MessageType.Info);
            }

            serializedObject.ApplyModifiedProperties();
        }
Exemple #3
0
        void DrawInspector(GDOC t, bool isSeparateWindow)
        {
            EditorGUIUtility.labelWidth    = 150;
            EditorGUIUtility.hierarchyMode = false;

            GUILayout.Space(10);

            if (t.initError != GDOC_Error.None)
            {
                GUILayout.Label("Init error: " + t.initError);
                GUILayout.Label("Please fix the error and re-enable this component.");
                return;
            }

            if (onBeginInspector != null)
            {
                onBeginInspector();
            }

            EditorGUILayout.BeginVertical(moduleStyle);

            GUILayout.Label("General", EditorStyles.boldLabel);

            FastPropertyField("enableOcclusionCulling", "Enabled");

            if (PlayerSettings.virtualRealitySupported)
            {
                FastPropertyField("vrMode", "VR Mode");

                var single = t.vrMode == GDOC_VRMode.SinglePass && PlayerSettings.stereoRenderingPath == StereoRenderingPath.SinglePass;
                var multi  = t.vrMode == GDOC_VRMode.MultiPass && PlayerSettings.stereoRenderingPath == StereoRenderingPath.MultiPass;

                if (!single && !multi)
                {
                    EditorGUILayout.HelpBox("PlayerSettings.stereoRenderingPath is " + PlayerSettings.stereoRenderingPath, MessageType.Warning);
                }
            }

            if (FastPropertyFieldCheck("directionalLight", "Directional Light"))
            {
                t.ValidateSettings();
            }

            t.ValidateSettings();

            if (t.lightError != GDOC_Error.None)
            {
                EditorGUILayout.HelpBox("Light error: " + t.lightError, MessageType.Warning);
            }

            FastPropertyField("accuracy", "Accuracy");
            FastPropertyField("prediction", "Prediction");

            FastPropertyField("minimumDistance", "Minimum distance");

            FastPropertyField("referenceObject", "Player object");

            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(moduleStyle);

            GUILayout.Space(5);
            GUILayout.Label("Object management", EditorStyles.boldLabel);

            EditorGUILayout.BeginVertical(innerModuleStyle);

            FastPropertyField("enableNewSceneScan", "Scan new scenes");

            if (t.enableNewSceneScan)
            {
                FastPropertyField("instantScanTimeLimit", "Time limit per frame (μs)");
            }

            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(innerModuleStyle);

            FastPropertyField("enableBackgroundScan", "Enable background scan");

            if (t.enableBackgroundScan)
            {
                FastPropertyField("backgroundScanTimeLimit", "Time limit per frame (μs)");
            }

            EditorGUILayout.EndVertical();

            if (t.enableBackgroundScan || t.enableNewSceneScan)
            {
                GUILayout.Space(5);
                objectSettings = EditorGUILayout.Foldout(objectSettings, "Objects");

                if (objectSettings)
                {
                    FastPropertyField("includeMeshRenderers", "Mesh renderers");
                    FastPropertyField("includeLODGroups", "LOD groups");
                    FastPropertyField("includeParticleSystems", "Particle systems");

                    FastPropertyField("includePointAndPointLights", "Point/Spot lights");
                    FastPropertyField("includeReflectionProbes", "Reflection Probes");

                    GUILayout.Space(5);

                    FastPropertyField("includeDisabledObjects", "Disabled objects");
                    FastPropertyField("includeDisabledComponents", "Disabled components");

                    GUILayout.Space(5);

                    GUILayout.Label("Dynamic by default", EditorStyles.boldLabel);

                    FastPropertyField("dynamicAnimators", "Animator children");

                    GUILayout.Space(5);
                }


                layerSettings = EditorGUILayout.Foldout(layerSettings, "Layers (management)");

                if (layerSettings)
                {
                    var layerManagementModes = serializedObject.FindProperty("layerManagementMode");

                    for (var i = 0; i < 32; i++)
                    {
                        var name = LayerMask.LayerToName(i);

                        if (string.IsNullOrEmpty(name))
                        {
                            continue;
                        }

                        name = i + ". " + name;

                        var mode = (GDOC_ManagementMode)layerManagementModes.GetArrayElementAtIndex(i).intValue;

                        var newMode = (GDOC_ManagementMode)EditorGUILayout.EnumPopup(name, mode, EditorStyles.popup);

                        if (newMode != mode)
                        {
                            layerManagementModes.GetArrayElementAtIndex(i).intValue = (int)newMode;
                        }
                    }
                }

                layerSettings2 = EditorGUILayout.Foldout(layerSettings2, "Layers (movement)");

                if (layerSettings2)
                {
                    var layerMovementModes = serializedObject.FindProperty("layerMovementMode");

                    for (var i = 0; i < 32; i++)
                    {
                        var name = LayerMask.LayerToName(i);

                        if (string.IsNullOrEmpty(name))
                        {
                            continue;
                        }

                        name = i + ". " + name;

                        var movementMode = (GDOC_UpdateMode)layerMovementModes.GetArrayElementAtIndex(i).intValue;

                        var newMovementMode = (GDOC_UpdateMode)EditorGUILayout.EnumPopup(name, movementMode, EditorStyles.popup);

                        if (newMovementMode != movementMode)
                        {
                            layerMovementModes.GetArrayElementAtIndex(i).intValue = (int)newMovementMode;
                        }
                    }
                }
            }

            EditorGUILayout.EndVertical();


            EditorGUILayout.BeginVertical(moduleStyle);

            GUILayout.Space(5);
            GUILayout.Label("Features", EditorStyles.boldLabel);

            EditorGUILayout.BeginVertical(innerModuleStyle);

            FastPropertyField("enableTeleportDetection", "Teleport Detection");

            if (t.enableTeleportDetection)
            {
                FastPropertyField("teleportDistance", "teleportDistance");
                FastPropertyField("teleportAngle", "teleportAngle");
                FastPropertyField("teleportRV", "teleportRV");
            }

            EditorGUILayout.EndVertical();

            EditorGUILayout.EndVertical();


            EditorGUILayout.BeginVertical(moduleStyle);

            if (GUILayout.Button("Debug", foldoutButtonStyle))
            {
                debugSettings = !debugSettings;
            }

            if (debugSettings)
            {
                FastPropertyField("showStats", "Show Info");
                FastPropertyField("editorLoggingMode", "Logging in Editor");
                FastPropertyField("buildLoggingMode", "Logging in Build");

                FastPropertyField("enableHotkeys", "Enable hotkeys");

                if (t.enableHotkeys)
                {
                    FastPropertyField("toggleOCKey", "Toggle GDOC");
                    FastPropertyField("toggleInfoKey", "Toggle info");
                    FastPropertyField("calcMetricsKey", "Calc metrics");
                    FastPropertyField("increaseAccuracyKey", "Increase accuracy");
                    FastPropertyField("decreaseAccuracyKey", "Decrease accuracy");
                }

                FastPropertyField("suspendOC", "Suspend OC");
                FastPropertyField("gizmoColor", "gizmoColor");
                FastPropertyField("massGizmoColor", "massGizmoColor");
                FastPropertyField("drawDebugGizmos", "drawDebugGizmos");
            }

            EditorGUILayout.EndVertical();


            EditorGUILayout.BeginVertical(moduleStyle);

            if (GUILayout.Button("Advanced settings", foldoutButtonStyle))
            {
                otherSettings = !otherSettings;
            }

            if (otherSettings)
            {
                FastPropertyField("autoDirectionalLight", "autoDirectionalLight");
                FastPropertyField("keepShadows", "keepShadows");
                // FastPropertyField("fastCameraSwitch", "fastCameraSwitch");

                FastPropertyField("preCullThreshold", "preCullThreshold");
                FastPropertyField("hideTime", "hideTime");

                FastPropertyField("fullDisableDistance", "fullDisableDistance");
                FastPropertyField("maxQueuedFrames", "maxQueuedFrames");
                FastPropertyField("occludeeInitState", "occludeeInitState");
                FastPropertyField("psOmnidirectionalBounds", "psOmnidirectionalBounds");

                FastPropertyField("clampShadowVolumes", "clampShadowVolumes");
                FastPropertyField("autoClampHeight", "autoClampHeight");

                EditorGUI.BeginDisabledGroup(t.autoClampHeight);
                FastPropertyField("clampHeight", "clampHeight");
                EditorGUI.EndDisabledGroup();


                #if GDOC_DEV
                GUILayout.Space(5);
                GUILayout.Label("Dev", EditorStyles.boldLabel);
                GUILayout.Space(5);

                FastPropertyField("forceSkipShadomap", "forceSkipShadomap");
                FastPropertyField("ignoreContainers", "ignoreContainers");
                FastPropertyField("downscaleDepth", "downscaleDepth");
                FastPropertyField("downscaleShadowmap", "downscaleShadowmap");
                FastPropertyField("optimizedVR", "optimizedVR");
                FastPropertyField("debugLayer", "debugLayer");
                FastPropertyField("kickstart", "kickstart");
                // FastPropertyField("debugTextures", "debugTextures"); // does nothing
                #endif
            }

            EditorGUILayout.EndVertical();

            GUILayout.Space(10);

            if (!string.IsNullOrEmpty(sceneMetrics))
            {
                EditorGUILayout.HelpBox(sceneMetrics, MessageType.Info);
            }

            if (GUILayout.Button("Calculate scene metrics"))
            {
                sceneMetrics = GDOC.CalculateSceneMetrics();
            }

            if (Application.isPlaying && t.isActiveAndEnabled)
            {
                if (GUILayout.Button("Scan active scenes"))
                {
                    GDOC.ScanActiveScenes();
                }

                if (GUILayout.Button("Restart"))
                {
                    GDOC.Restart();
                }
            }

            serializedObject.ApplyModifiedProperties();

            EditorGUIUtility.labelWidth = 0;

            if (isSeparateWindow)
            {
                EditorGUILayout.EndVertical();
            }
        }