Example #1
0
        public override void OnInspectorGUI()
        {
            if (serializedObject == null || serializedObject.targetObject == null)
            {
                return;
            }


            if (m_SharedDepthBuffer == null)
            {
                m_SharedDepthBuffer = serializedObject.FindProperty(kSharedDepthBuffer);
            }
            if (m_DashSupport == null)
            {
                m_DashSupport = serializedObject.FindProperty(kDashSupport);
            }
            if (m_StereoRenderingModeDesktop == null)
            {
                m_StereoRenderingModeDesktop = serializedObject.FindProperty(kStereoRenderingModeDesktop);
            }
            if (m_StereoRenderingModeAndroid == null)
            {
                m_StereoRenderingModeAndroid = serializedObject.FindProperty(kStereoRenderingModeAndroid);
            }
            if (m_V2Signing == null)
            {
                m_V2Signing = serializedObject.FindProperty(kV2Signing);
            }


            serializedObject.Update();

            BuildTargetGroup selectedBuildTargetGroup = EditorGUILayout.BeginBuildTargetSelectionGrouping();

            EditorGUILayout.Space();

            EditorGUILayout.BeginVertical(GUILayout.ExpandWidth(true));
            if (EditorApplication.isPlayingOrWillChangePlaymode)
            {
                EditorGUILayout.HelpBox("Oculus settings cannnot be changed when the editor is in play mode.", MessageType.Info);
                EditorGUILayout.Space();
            }
            EditorGUI.BeginDisabledGroup(EditorApplication.isPlayingOrWillChangePlaymode);
            if (selectedBuildTargetGroup == BuildTargetGroup.Standalone)
            {
                EditorGUILayout.PropertyField(m_SharedDepthBuffer, s_SharedDepthBufferLabel);
                EditorGUILayout.PropertyField(m_DashSupport, s_DashSupportLabel);
                EditorGUILayout.PropertyField(m_StereoRenderingModeDesktop, s_StereoRenderingMode);
            }
            else if (selectedBuildTargetGroup == BuildTargetGroup.Android)
            {
                EditorGUILayout.PropertyField(m_StereoRenderingModeAndroid, s_StereoRenderingMode);
                EditorGUILayout.PropertyField(m_V2Signing, s_V2Signing);
            }
            EditorGUI.EndDisabledGroup();
            EditorGUILayout.EndVertical();
            EditorGUILayout.EndBuildTargetSelectionGrouping();

            serializedObject.ApplyModifiedProperties();
        }
Example #2
0
        public override void OnInspectorGUI()
        {
            if (serializedObject == null || serializedObject.targetObject == null)
            {
                return;
            }

            serializedObject.Update();

            BuildTargetGroup selectedBuildTargetGroup = EditorGUILayout.BeginBuildTargetSelectionGrouping();

            EditorGUILayout.Space();

            EditorGUILayout.BeginVertical(GUILayout.ExpandWidth(true));
            if (EditorApplication.isPlayingOrWillChangePlaymode)
            {
                EditorGUILayout.HelpBox("PicoXR settings cannot be changed when the editor is in play mode.", MessageType.Info);
                EditorGUILayout.Space();
            }
            EditorGUI.BeginDisabledGroup(EditorApplication.isPlayingOrWillChangePlaymode);
            if (selectedBuildTargetGroup == BuildTargetGroup.Android)
            {
                EditorGUILayout.PropertyField(stereoRenderingModeAndroid, guiStereoRenderingMode);
                EditorGUILayout.PropertyField(systemDisplayFrequency, guiDisplayFrequency);
            }
            EditorGUI.EndDisabledGroup();
            EditorGUILayout.EndVertical();
            EditorGUILayout.EndBuildTargetSelectionGrouping();

            serializedObject.ApplyModifiedProperties();
        }
        public override void OnInspectorGUI()
        {
            var buildTargetGroup = EditorGUILayout.BeginBuildTargetSelectionGrouping();

            OpenXRPackageSettings settings = serializedObject.targetObject as OpenXRPackageSettings;

            var openXrSettings = settings.GetSettingsForBuildTargetGroup(buildTargetGroup);

            var editor = UnityEditor.Editor.CreateEditor(openXrSettings);

            EditorGUI.BeginDisabledGroup(EditorApplication.isPlaying);

            EditorGUILayout.BeginVertical();
            editor.DrawDefaultInspector();

            if (buildTargetGroup == BuildTargetGroup.Standalone)
            {
                GUILayout.Space(Content.k_Space);
                OpenXRRuntimeSelector.DrawSelector();
            }

            EditorGUILayout.EndVertical();

            EditorGUI.EndDisabledGroup();

            EditorGUILayout.EndBuildTargetSelectionGrouping();
        }
        /// <summary>
        /// Ends the display block of the base settings. Needs to be called if DisplayBaseSettingsBegin() is called.
        /// </summary>
        public void DisplayBaseSettingsEnd()
        {
            EditorGUILayout.EndBuildTargetSelectionGrouping(); // Start happens in provider Editor
            EditorGUI.EndDisabledGroup();
            EditorGUILayout.EndVertical();

            EditorGUIUtility.hierarchyMode = m_PreviousHierarchyMode;

            serializedObject.ApplyModifiedProperties();
            AssetDatabase.SaveAssets();
        }
Example #5
0
    private void OnGUI()
    {
        BuildTargetGroup selectedBuildTargetGroup = EditorGUILayout.BeginBuildTargetSelectionGrouping();

        if (selectedBuildTargetGroup == BuildTargetGroup.Android)
        {
            EditorGUILayout.LabelField("Android specific things");
        }
        if (selectedBuildTargetGroup == BuildTargetGroup.Standalone)
        {
            EditorGUILayout.LabelField("Standalone specific things");
        }
        EditorGUILayout.EndBuildTargetSelectionGrouping();
    }
        public override void OnInspectorGUI()
        {
            var buildTargetGroup = EditorGUILayout.BeginBuildTargetSelectionGrouping();

            OpenXRProjectValidationWindow.SetSelectedBuildTargetGroup(buildTargetGroup);

            OpenXRPackageSettings settings = serializedObject.targetObject as OpenXRPackageSettings;

            scrollPos = EditorGUILayout.BeginScrollView(scrollPos);

            EditorGUI.BeginDisabledGroup(EditorApplication.isPlaying);

            EditorGUILayout.BeginVertical();

            var openXrSettings           = settings.GetSettingsForBuildTargetGroup(buildTargetGroup);
            var serializedOpenXrSettings = new SerializedObject(openXrSettings);

            EditorGUIUtility.labelWidth = 200;
            DrawPropertiesExcluding(serializedOpenXrSettings, "m_Script");
            EditorGUIUtility.labelWidth = 0;

            if (serializedOpenXrSettings.hasModifiedProperties)
            {
                serializedOpenXrSettings.ApplyModifiedProperties();
            }

            if (buildTargetGroup == BuildTargetGroup.Standalone)
            {
                EditorGUILayout.Space();
                OpenXRRuntimeSelector.DrawSelector();
            }

            EditorGUILayout.EndVertical();


            if (m_FeatureEditor != null)
            {
                EditorGUILayout.Space();
                m_FeatureEditor.OnGUI(buildTargetGroup);
            }
            EditorGUI.EndDisabledGroup();

            EditorGUILayout.EndBuildTargetSelectionGrouping();

            EditorGUILayout.EndScrollView();
        }
Example #7
0
        public override void OnInspectorGUI()
        {
            if (serializedObject == null || serializedObject.targetObject == null)
            {
                return;
            }

            WindowsMRPackageSettings settings = serializedObject.targetObject as WindowsMRPackageSettings;

            BuildTargetGroup buildTargetGroup = EditorGUILayout.BeginBuildTargetSelectionGrouping();

            if (buildTargetGroup == BuildTargetGroup.Standalone || buildTargetGroup == BuildTargetGroup.WSA)
            {
                serializedObject.Update();

                if (buildTargetGroup == BuildTargetGroup.WSA)
                {
                    m_ShowBuildSettings = EditorGUILayout.Foldout(m_ShowBuildSettings, s_ShowBuildSettingsLabel);
                    if (m_ShowBuildSettings)
                    {
                        var serializedSettingsObject = new SerializedObject(settings.GetBuildSettingsForBuildTargetGroup(buildTargetGroup));
                        serializedSettingsObject.Update();

                        SerializedProperty forcePrimaryWindowHologrpahic = serializedSettingsObject.FindProperty(k_ForcePrimaryWindowHolographic);

                        EditorGUI.indentLevel++;
                        EditorGUILayout.PropertyField(forcePrimaryWindowHologrpahic, s_ForcePrimaryWindowHologrpahicLabel);
                        EditorGUI.indentLevel--;
                        serializedSettingsObject.ApplyModifiedProperties();
                    }
                }

                EditorGUILayout.Space();

                if (buildTargetGroup == BuildTargetGroup.WSA)
                {
                    m_ShowRuntimeSettings = EditorGUILayout.Foldout(m_ShowRuntimeSettings, s_ShowRuntimeSettingsLabel);
                }
                else
                {
                    m_ShowRuntimeSettings = true;
                }

                if (m_ShowRuntimeSettings)
                {
                    var serializedSettingsObject = new SerializedObject(settings.GetSettingsForBuildTargetGroup(buildTargetGroup));
                    serializedSettingsObject.Update();

                    SerializedProperty depthBufferFormat = serializedSettingsObject.FindProperty(k_DepthBufferFormat);
                    SerializedProperty sharedDepthBuffer = serializedSettingsObject.FindProperty(k_SharedDepthBuffer);

                    EditorGUI.indentLevel++;
                    EditorGUILayout.PropertyField(depthBufferFormat, s_DepthBufferFormatLabel);
                    EditorGUILayout.Space();
                    EditorGUILayout.PropertyField(sharedDepthBuffer, s_SharedDepthBufferLabel);
                    EditorGUI.indentLevel--;
                    serializedSettingsObject.ApplyModifiedProperties();
                }
                serializedObject.ApplyModifiedProperties();
            }
            else
            {
                EditorGUILayout.HelpBox("Settings for this package are unsupported for this target platform.", MessageType.Info);
            }
            EditorGUILayout.EndBuildTargetSelectionGrouping();
        }
Example #8
0
        public override void OnInspectorGUI()
        {
            if (serializedObject == null || serializedObject.targetObject == null)
            {
                return;
            }

            if (m_SharedDepthBuffer == null)
            {
                m_SharedDepthBuffer = serializedObject.FindProperty(kSharedDepthBuffer);
            }
            if (m_DashSupport == null)
            {
                m_DashSupport = serializedObject.FindProperty(kDashSupport);
            }
            if (m_StereoRenderingModeDesktop == null)
            {
                m_StereoRenderingModeDesktop = serializedObject.FindProperty(kStereoRenderingModeDesktop);
            }
            if (m_StereoRenderingModeAndroid == null)
            {
                m_StereoRenderingModeAndroid = serializedObject.FindProperty(kStereoRenderingModeAndroid);
            }
            if (m_LowOverheadMode == null)
            {
                m_LowOverheadMode = serializedObject.FindProperty(kLowOverheadMode);
            }
            if (m_OptimizeBufferDiscards == null)
            {
                m_OptimizeBufferDiscards = serializedObject.FindProperty(kOptimizeBufferDiscards);
            }
            if (m_PhaseSync == null)
            {
                m_PhaseSync = serializedObject.FindProperty(kPhaseSync);
            }
            if (m_SubsampledLayout == null)
            {
                m_SubsampledLayout = serializedObject.FindProperty(kSubsampledLayout);
            }
            if (m_TargetQuest == null)
            {
                m_TargetQuest = serializedObject.FindProperty(kTargetQuest);
            }
            if (m_TargetQuest2 == null)
            {
                m_TargetQuest2 = serializedObject.FindProperty(kTargetQuest2);
            }
            if (m_SystemSplashScreen == null)
            {
                m_SystemSplashScreen = serializedObject.FindProperty(kSystemSplashScreen);
            }

            serializedObject.Update();

            EditorGUIUtility.labelWidth = 220.0f;

            BuildTargetGroup selectedBuildTargetGroup = EditorGUILayout.BeginBuildTargetSelectionGrouping();

            EditorGUILayout.Space();

            EditorGUILayout.BeginVertical(GUILayout.ExpandWidth(true));
            if (EditorApplication.isPlayingOrWillChangePlaymode)
            {
                EditorGUILayout.HelpBox("Oculus settings cannnot be changed when the editor is in play mode.", MessageType.Info);
                EditorGUILayout.Space();
            }
            EditorGUI.BeginDisabledGroup(EditorApplication.isPlayingOrWillChangePlaymode);
            if (selectedBuildTargetGroup == BuildTargetGroup.Standalone)
            {
                EditorGUILayout.PropertyField(m_StereoRenderingModeDesktop, s_StereoRenderingModeLabel);
                EditorGUILayout.PropertyField(m_SharedDepthBuffer, s_SharedDepthBufferLabel);
                EditorGUILayout.PropertyField(m_DashSupport, s_DashSupportLabel);
            }
            else if (selectedBuildTargetGroup == BuildTargetGroup.Android)
            {
                EditorGUILayout.PropertyField(m_StereoRenderingModeAndroid, s_StereoRenderingModeLabel);
                EditorGUILayout.PropertyField(m_LowOverheadMode, s_LowOverheadModeLabel);
                EditorGUILayout.PropertyField(m_OptimizeBufferDiscards, s_OptimizeBufferDiscardsLabel);
                EditorGUILayout.PropertyField(m_PhaseSync, s_PhaseSyncLabel);
#if UNITY_2020_1_OR_NEWER
                EditorGUILayout.PropertyField(m_SubsampledLayout, s_SubsampledLayoutLabel);
#endif

                EditorGUILayout.Space();

                GUILayout.Label(s_TargetDevicesLabel, EditorStyles.boldLabel);

                EditorGUILayout.PropertyField(m_TargetQuest, s_TargetQuestLabel);
                EditorGUILayout.PropertyField(m_TargetQuest2, s_TargetQuest2Label);

                EditorGUILayout.Space();

                EditorGUILayout.PropertyField(m_SystemSplashScreen, s_SystemSplashScreen);
            }
            EditorGUI.EndDisabledGroup();
            EditorGUILayout.EndVertical();
            EditorGUILayout.EndBuildTargetSelectionGrouping();

            serializedObject.ApplyModifiedProperties();

            EditorGUIUtility.labelWidth = 0.0f;
        }
Example #9
0
        /// <summary>See <see href="https://docs.unity3d.com/ScriptReference/SettingsProvider.html">SettingsProvider documentation</see>.</summary>
        public override void OnGUI(string searchContext)
        {
            if (m_SettingsWrapper != null && m_SettingsWrapper.targetObject != null)
            {
                m_SettingsWrapper.Update();

                BuildTargetGroup buildTargetGroup = EditorGUILayout.BeginBuildTargetSelectionGrouping();

                XRGeneralSettings settings = currentSettings.SettingsForBuildTarget(buildTargetGroup);
                if (settings == null)
                {
                    settings = ScriptableObject.CreateInstance <XRGeneralSettings>() as XRGeneralSettings;
                    currentSettings.SetSettingsForBuildTarget(buildTargetGroup, settings);
                    settings.name = $"{buildTargetGroup.ToString()} Settings";
                    AssetDatabase.AddObjectToAsset(settings, AssetDatabase.GetAssetOrScenePath(currentSettings));
                }

                var serializedSettingsObject = new SerializedObject(settings);
                serializedSettingsObject.Update();

                SerializedProperty initOnStart = serializedSettingsObject.FindProperty("m_InitManagerOnStart");
                EditorGUILayout.PropertyField(initOnStart, s_LoaderInitOnStartLabel);

                SerializedProperty loaderProp = serializedSettingsObject.FindProperty("m_LoaderManagerInstance");

                if (!CachedSettingsEditor.ContainsKey(buildTargetGroup))
                {
                    CachedSettingsEditor.Add(buildTargetGroup, null);
                }

                if (loaderProp.objectReferenceValue == null)
                {
                    var xrManagerSettings = ScriptableObject.CreateInstance <XRManagerSettings>() as XRManagerSettings;
                    xrManagerSettings.name = $"{buildTargetGroup.ToString()} Loaders";
                    AssetDatabase.AddObjectToAsset(xrManagerSettings, AssetDatabase.GetAssetOrScenePath(currentSettings));
                    loaderProp.objectReferenceValue = xrManagerSettings;
                    serializedSettingsObject.ApplyModifiedProperties();
                }

                var obj = loaderProp.objectReferenceValue;

                if (obj != null)
                {
                    loaderProp.objectReferenceValue = obj;

                    if (CachedSettingsEditor[buildTargetGroup] == null)
                    {
                        CachedSettingsEditor[buildTargetGroup] = Editor.CreateEditor(obj);

                        if (CachedSettingsEditor[buildTargetGroup] == null)
                        {
                            Debug.LogError("Failed to create a view for XR Manager Settings Instance");
                        }
                    }

                    if (CachedSettingsEditor[buildTargetGroup] != null)
                    {
                        CachedSettingsEditor[buildTargetGroup].OnInspectorGUI();
                    }
                }
                else if (obj == null)
                {
                    settings.AssignedSettings       = null;
                    loaderProp.objectReferenceValue = null;
                }

                serializedSettingsObject.ApplyModifiedProperties();

                EditorGUILayout.EndBuildTargetSelectionGrouping();

                m_SettingsWrapper.ApplyModifiedProperties();
            }

            base.OnGUI(searchContext);
        }
Example #10
0
        private void DisplayLoaderSelectionUI()
        {
            if (!m_HasCompletedRequest)
            {
                return;
            }

            if (!m_HasKNownLocalLoaders)
            {
                if (!m_XRPackages.Any())
                {
                    EditorGUILayout.HelpBox(Content.k_ProvidersUnavailable, MessageType.Error);
                    return;
                }

                if (!m_HasInstalledProviders)
                {
                    EditorGUILayout.HelpBox(Content.k_NeedToInstallAProvider, MessageType.Warning);
                    return;
                }
            }

            BuildTargetGroup buildTargetGroup   = EditorGUILayout.BeginBuildTargetSelectionGrouping();
            bool             buildTargetChanged = m_LastBuildTargetGroup != buildTargetGroup;

            if (buildTargetChanged)
            {
                m_LastBuildTargetGroup = buildTargetGroup;
            }

            XRGeneralSettings settings = currentSettings.SettingsForBuildTarget(buildTargetGroup);

            if (settings == null)
            {
                settings = ScriptableObject.CreateInstance <XRGeneralSettings>() as XRGeneralSettings;
                currentSettings.SetSettingsForBuildTarget(buildTargetGroup, settings);
                settings.name = $"{buildTargetGroup.ToString()} Settings";
                AssetDatabase.AddObjectToAsset(settings, AssetDatabase.GetAssetOrScenePath(currentSettings));
            }

            var serializedSettingsObject = new SerializedObject(settings);

            serializedSettingsObject.Update();

            SerializedProperty initOnStart = serializedSettingsObject.FindProperty("m_InitManagerOnStart");

            EditorGUILayout.PropertyField(initOnStart, Content.s_LoaderInitOnStartLabel);

            SerializedProperty loaderProp = serializedSettingsObject.FindProperty("m_LoaderManagerInstance");

            if (!CachedSettingsEditor.ContainsKey(buildTargetGroup))
            {
                CachedSettingsEditor.Add(buildTargetGroup, null);
            }

            if (loaderProp.objectReferenceValue == null)
            {
                var xrManagerSettings = ScriptableObject.CreateInstance <XRManagerSettings>() as XRManagerSettings;
                xrManagerSettings.name = $"{buildTargetGroup.ToString()} Providers";
                AssetDatabase.AddObjectToAsset(xrManagerSettings, AssetDatabase.GetAssetOrScenePath(currentSettings));
                loaderProp.objectReferenceValue = xrManagerSettings;
                serializedSettingsObject.ApplyModifiedProperties();
            }

            var obj = loaderProp.objectReferenceValue;

            if (obj != null)
            {
                loaderProp.objectReferenceValue = obj;

                if (CachedSettingsEditor[buildTargetGroup] == null)
                {
                    CachedSettingsEditor[buildTargetGroup] = Editor.CreateEditor(obj) as XRManagerSettingsEditor;

                    if (CachedSettingsEditor[buildTargetGroup] == null)
                    {
                        Debug.LogError("Failed to create a view for XR Manager Settings Instance");
                    }
                }

                if (CachedSettingsEditor[buildTargetGroup] != null)
                {
                    if (buildTargetChanged)
                    {
                        CachedSettingsEditor[buildTargetGroup].BuildTarget = buildTargetGroup;
                        CachedSettingsEditor[buildTargetGroup].Reload();
                    }
                    CachedSettingsEditor[buildTargetGroup].OnInspectorGUI();
                }
            }
            else if (obj == null)
            {
                settings.AssignedSettings       = null;
                loaderProp.objectReferenceValue = null;
            }

            EditorGUILayout.EndBuildTargetSelectionGrouping();

            serializedSettingsObject.ApplyModifiedProperties();
        }
    public void EditorGUILayoutExamples()
    {
        EditorGUILayout.LabelField("Hello World!");

        Rect rect = EditorGUILayout.GetControlRect(false, 50);

        GUI.Button(rect, GUIContent.none);


        gradient = EditorGUILayout.GradientField("Gradient", gradient);
        //EditorGUILayout.HelpBox("Hello, World !", MessageType.Info);
        //EditorGUILayout.HelpBox("Hello, World !", MessageType.Error);
        EditorGUILayout.HelpBox("Hello, World !", MessageType.Warning);
        //EditorGUILayout.HelpBox("Hello, World !", MessageType.None);
        EditorGUILayout.SelectableLabel("This is a selectable label");

        EditorGUILayout.DropdownButton(GUIContent.none, FocusType.Keyboard);

        EditorGUILayout.Space();

        EditorGUILayout.BeginHorizontal("Toolbar", GUILayout.ExpandWidth(true));
        {
            if (GUILayout.Button("Clear", "ToolbarButton", GUILayout.Width(45f)))
            {
                Debug.Log("You click Clear button");
            }
            // Create space between Clear and Collapse button.
            GUILayout.Space(5f);
            // Create toggles button.
            collapsed   = GUILayout.Toggle(collapsed, "Collapse", "ToolbarButton");
            clearOnPlay = GUILayout.Toggle(clearOnPlay, "Clear on Play", "ToolbarButton");
            // Push content to be what they should be. (ex. width)
            GUILayout.FlexibleSpace();
        }
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.EditorToolbar(vertexTool);

        bounds      = EditorGUILayout.BoundsField("Bounds", bounds);
        doubleValue = EditorGUILayout.DelayedDoubleField("Delayed Double", doubleValue);

        BuildTargetGroup buildTargetGroup = EditorGUILayout.BeginBuildTargetSelectionGrouping();

        {
            EditorGUI.indentLevel++;
            EditorGUILayout.LabelField($"BuildTarget:{buildTargetGroup}");
            EditorGUI.indentLevel--;
        }
        EditorGUILayout.EndBuildTargetSelectionGrouping();


        using (var v = new EditorGUILayout.VerticalScope("button"))
        {
            Rect r = new Rect(v.rect);
            r.height = r.height / 2;
            if (GUI.Button(r, GUIContent.none))
            {
                Debug.Log("Go here");
            }
            GUILayout.Label("I'm inside the button");
            GUILayout.Label("So am I");
            GUILayout.Label($"{v.rect.width} x {v.rect.height}");
        }

        //
        m_ShowExtraFields.target = EditorGUILayout.ToggleLeft("Show extra fields", m_ShowExtraFields.target);

        //Extra block that can be toggled on and off.
        using (var group = new EditorGUILayout.FadeGroupScope(m_ShowExtraFields.faded))
        {
            if (group.visible)
            {
                EditorGUI.indentLevel++;
                EditorGUILayout.PrefixLabel("Color");
                m_Color = EditorGUILayout.ColorField(m_Color);
                EditorGUILayout.PrefixLabel("Text");
                m_String = EditorGUILayout.TextField(m_String);
                EditorGUILayout.PrefixLabel("Number");
                m_Number = EditorGUILayout.IntSlider(m_Number, 0, 10);
                EditorGUI.indentLevel--;
            }
        }


        using (var h = new EditorGUILayout.HorizontalScope())
        {
            using (var scrollView = new EditorGUILayout.ScrollViewScope(scrollPos, GUILayout.Width(100), GUILayout.Height(100)))
            {
                scrollPos = scrollView.scrollPosition;
                GUILayout.Label(t);
            }
            if (GUILayout.Button("Add More Text", GUILayout.Width(100), GUILayout.Height(100)))
            {
                t += " \nAnd this is more text!";
            }
        }
        if (GUILayout.Button("Clear"))
        {
            t = "";
        }

        using (var posGroup = new EditorGUILayout.ToggleGroupScope("Align position", posGroupEnabled))
        {
            EditorGUI.indentLevel++;
            posGroupEnabled = posGroup.enabled;
            pos[0]          = EditorGUILayout.Toggle("x", pos[0]);
            pos[1]          = EditorGUILayout.Toggle("y", pos[1]);
            pos[2]          = EditorGUILayout.Toggle("z", pos[2]);
            EditorGUI.indentLevel--;
        }
    }
        public override void OnInspectorGUI()
        {
            if (serializedObject == null || serializedObject.targetObject == null)
            {
                return;
            }

            if (m_StereoRenderingMode == null)
            {
                m_StereoRenderingMode = serializedObject.FindProperty(k_StereoRenderingMode);
            }
            if (m_SeparateCullPass == null)
            {
                m_SeparateCullPass = serializedObject.FindProperty(k_SeparateCullPass);
            }
            if (m_FoveatedRendering == null)
            {
                m_FoveatedRendering = serializedObject.FindProperty(k_FoveatedRendering);
            }
            if (m_ContextScalingFactor == null)
            {
                m_ContextScalingFactor = serializedObject.FindProperty(k_ContextScalingFactor);
            }
            if (m_FocusScalingFactor == null)
            {
                m_FocusScalingFactor = serializedObject.FindProperty(k_FocusScalingFactor);
            }
            if (m_Opaque == null)
            {
                m_Opaque = serializedObject.FindProperty(k_Opaque);
            }
            if (m_FaceLocked == null)
            {
                m_FaceLocked = serializedObject.FindProperty(k_FaceLocked);
            }
            if (m_FlipY == null)
            {
                m_FlipY = serializedObject.FindProperty(k_FlipY);
            }
            if (m_OcclusionMesh == null)
            {
                m_OcclusionMesh = serializedObject.FindProperty(k_OcclusionMesh);
            }
            if (m_SessionPriority == null)
            {
                m_SessionPriority = serializedObject.FindProperty(k_SessionPriority);
            }
            if (m_SubmitDepth == null)
            {
                m_SubmitDepth = serializedObject.FindProperty(k_SubmitDepth);
            }
            if (m_DepthSorting == null)
            {
                m_DepthSorting = serializedObject.FindProperty(k_DepthSorting);
            }
            if (m_DepthTestRange == null)
            {
                m_DepthTestRange = serializedObject.FindProperty(k_DepthTestRange);
            }
            if (m_DepthTestNearZ == null)
            {
                m_DepthTestNearZ = serializedObject.FindProperty(k_DepthTestNearZ);
            }
            if (m_DepthTestFarZ == null)
            {
                m_DepthTestFarZ = serializedObject.FindProperty(k_DepthTestFarZ);
            }

            serializedObject.Update();

            BuildTargetGroup selectedBuildTargetGroup = EditorGUILayout.BeginBuildTargetSelectionGrouping();

            EditorGUILayout.Space();

            EditorGUILayout.BeginVertical(GUILayout.ExpandWidth(true));
            if (EditorApplication.isPlayingOrWillChangePlaymode)
            {
                EditorGUILayout.HelpBox("Varjo settings can't be changed when the editor is in play mode. Use the functions in Varjo.XR.VarjoRendering to modify the settings in runtime.", MessageType.Info);
                EditorGUILayout.Space();
            }
            EditorGUI.BeginDisabledGroup(EditorApplication.isPlayingOrWillChangePlaymode);
            if (selectedBuildTargetGroup == BuildTargetGroup.Standalone)
            {
                EditorGUILayout.PropertyField(m_StereoRenderingMode, s_StereoRenderingModeLabel);
                EditorGUILayout.PropertyField(m_SeparateCullPass, s_SeparateCullPassLabel);
                EditorGUILayout.PropertyField(m_FoveatedRendering, s_FoveatedRenderingLabel);
                EditorGUILayout.PropertyField(m_ContextScalingFactor, s_ContextScalingFactorLabel);
                EditorGUILayout.PropertyField(m_FocusScalingFactor, s_FocusScalingFactorLabel);
                EditorGUILayout.PropertyField(m_Opaque, s_OpaqueLabel);
                EditorGUILayout.PropertyField(m_FaceLocked, s_FaceLockedLabel);
                EditorGUILayout.PropertyField(m_FlipY, s_FlipYLabel);
                EditorGUILayout.PropertyField(m_OcclusionMesh, s_OcclusionMeshLabel);
                EditorGUILayout.PropertyField(m_SessionPriority, s_SessionPriorityLabel);
                EditorGUILayout.PropertyField(m_SubmitDepth, s_SubmitDepthLabel);
                EditorGUILayout.PropertyField(m_DepthSorting, s_DepthSortingLabel);
                EditorGUILayout.PropertyField(m_DepthTestRange, s_DepthTestRangeLabel);
                EditorGUILayout.Slider(m_DepthTestNearZ, 0f, m_DepthTestFarZ.floatValue - 0.00001f);
                EditorGUILayout.Slider(m_DepthTestFarZ, m_DepthTestNearZ.floatValue + 0.00001f, 50f);
            }
            else
            {
                EditorGUILayout.HelpBox("Varjo XR plugin is not supported for this target platform.", MessageType.Info);
            }
            EditorGUI.EndDisabledGroup();
            EditorGUILayout.EndVertical();
            EditorGUILayout.EndBuildTargetSelectionGrouping();

            serializedObject.ApplyModifiedProperties();
        }
Example #13
0
        public override void OnInspectorGUI()
        {
            if (serializedObject == null || serializedObject.targetObject == null)
            {
                return;
            }

            if (m_SharedDepthBuffer == null)
            {
                m_SharedDepthBuffer = serializedObject.FindProperty(kSharedDepthBuffer);
            }
            if (m_DashSupport == null)
            {
                m_DashSupport = serializedObject.FindProperty(kDashSupport);
            }
            if (m_StereoRenderingModeDesktop == null)
            {
                m_StereoRenderingModeDesktop = serializedObject.FindProperty(kStereoRenderingModeDesktop);
            }
            if (m_StereoRenderingModeAndroid == null)
            {
                m_StereoRenderingModeAndroid = serializedObject.FindProperty(kStereoRenderingModeAndroid);
            }
            if (m_LowOverheadMode == null)
            {
                m_LowOverheadMode = serializedObject.FindProperty(kLowOverheadMode);
            }
            if (m_ProtectedContext == null)
            {
                m_ProtectedContext = serializedObject.FindProperty(kProtectedContext);
            }
            if (m_FocusAware == null)
            {
                m_FocusAware = serializedObject.FindProperty(kFocusAware);
            }
            if (m_OptimizeBufferDiscards == null)
            {
                m_OptimizeBufferDiscards = serializedObject.FindProperty(kOptimizeBufferDiscards);
            }

            serializedObject.Update();

            EditorGUIUtility.labelWidth = 220.0f;

            BuildTargetGroup selectedBuildTargetGroup = EditorGUILayout.BeginBuildTargetSelectionGrouping();

            EditorGUILayout.Space();

            EditorGUILayout.BeginVertical(GUILayout.ExpandWidth(true));
            if (EditorApplication.isPlayingOrWillChangePlaymode)
            {
                EditorGUILayout.HelpBox("Oculus settings cannnot be changed when the editor is in play mode.", MessageType.Info);
                EditorGUILayout.Space();
            }
            EditorGUI.BeginDisabledGroup(EditorApplication.isPlayingOrWillChangePlaymode);
            if (selectedBuildTargetGroup == BuildTargetGroup.Standalone)
            {
                EditorGUILayout.PropertyField(m_StereoRenderingModeDesktop, s_StereoRenderingModeLabel);
                EditorGUILayout.PropertyField(m_SharedDepthBuffer, s_SharedDepthBufferLabel);
                EditorGUILayout.PropertyField(m_DashSupport, s_DashSupportLabel);
            }
            else if (selectedBuildTargetGroup == BuildTargetGroup.Android)
            {
                EditorGUILayout.PropertyField(m_StereoRenderingModeAndroid, s_StereoRenderingModeLabel);
                EditorGUILayout.PropertyField(m_LowOverheadMode, s_LowOverheadModeLabel);
                EditorGUILayout.PropertyField(m_ProtectedContext, s_ProtectedContextLabel);
                EditorGUILayout.PropertyField(m_OptimizeBufferDiscards, s_OptimizeBufferDiscardsLabel);
                EditorGUILayout.PropertyField(m_FocusAware, s_FocusAwareLabel);
            }
            EditorGUI.EndDisabledGroup();
            EditorGUILayout.EndVertical();
            EditorGUILayout.EndBuildTargetSelectionGrouping();

            serializedObject.ApplyModifiedProperties();

            EditorGUIUtility.labelWidth = 0.0f;
        }
        /// <summary>
        /// GUI for WindowsMRSettingsEditor class.
        /// </summary>
        public override void OnInspectorGUI()
        {
            if (serializedObject == null || serializedObject.targetObject == null)
            {
                return;
            }

            WindowsMRPackageSettings settings = serializedObject.targetObject as WindowsMRPackageSettings;

            BuildTargetGroup buildTargetGroup = EditorGUILayout.BeginBuildTargetSelectionGrouping();

            if (buildTargetGroup == BuildTargetGroup.Standalone || buildTargetGroup == BuildTargetGroup.WSA)
            {
                var mgmtsettings = XRGeneralSettingsPerBuildTarget.XRGeneralSettingsForBuildTarget(buildTargetGroup);

                serializedObject.Update();

                m_ShowBuildSettings = EditorGUILayout.Foldout(m_ShowBuildSettings, s_ShowBuildSettingsLabel);
                if (m_ShowBuildSettings)
                {
                    var serializedSettingsObject = new SerializedObject(settings.GetBuildSettingsForBuildTargetGroup(buildTargetGroup));
                    serializedSettingsObject.Update();

                    SerializedProperty holographicRemoting           = serializedSettingsObject.FindProperty(k_HolographicRemoting);
                    SerializedProperty forcePrimaryWindowHolographic = serializedSettingsObject.FindProperty(k_ForcePrimaryWindowHolographic);
                    EditorGUI.indentLevel++;

                    if (buildTargetGroup == BuildTargetGroup.WSA)
                    {
                        EditorGUI.BeginDisabledGroup(holographicRemoting.boolValue);

                        if (holographicRemoting.boolValue && forcePrimaryWindowHolographic.boolValue)
                        {
                            forcePrimaryWindowHolographic.boolValue = false;
                            Debug.LogWarning("Holographic remoting has been enabled. This requires use of primary window to be disabled.");
                        }

                        EditorGUILayout.PropertyField(forcePrimaryWindowHolographic, s_forcePrimaryWindowHolographicLabel);
                        EditorGUI.EndDisabledGroup();
                        EditorGUILayout.Space();
                    }

                    EditorGUILayout.PropertyField(holographicRemoting, s_HolographicRemotingLabel);
                    EditorGUI.indentLevel--;


                    if (mgmtsettings != null)
                    {
                        if (holographicRemoting.boolValue == mgmtsettings.InitManagerOnStart)
                        {
                            mgmtsettings.InitManagerOnStart = !holographicRemoting.boolValue;
                            if (!mgmtsettings.InitManagerOnStart)
                            {
                                Debug.LogWarning("Holographic remoting has been enabled. This requires XR Plug-in Management Initialize on Startup to be disabled.");
                            }
                            else
                            {
                                Debug.LogWarning("Holographic remoting has been disabled. XR Plug-in Management Initialize on Startup has been re-enabled.");
                            }
                        }
                    }

                    serializedSettingsObject.ApplyModifiedProperties();
                }


                EditorGUILayout.Space();

                m_ShowRuntimeSettings = EditorGUILayout.Foldout(m_ShowRuntimeSettings, s_ShowRuntimeSettingsLabel);

                if (m_ShowRuntimeSettings)
                {
                    var serializedSettingsObject = new SerializedObject(settings.GetSettingsForBuildTargetGroup(buildTargetGroup));
                    serializedSettingsObject.Update();

                    SerializedProperty depthBufferFormat = serializedSettingsObject.FindProperty(k_DepthBufferFormat);
                    SerializedProperty sharedDepthBuffer = serializedSettingsObject.FindProperty(k_SharedDepthBuffer);

                    EditorGUI.indentLevel++;
                    EditorGUILayout.PropertyField(depthBufferFormat, s_DepthBufferFormatLabel);
                    EditorGUILayout.Space();
                    EditorGUILayout.PropertyField(sharedDepthBuffer, s_SharedDepthBufferLabel);
                    EditorGUI.indentLevel--;
                    serializedSettingsObject.ApplyModifiedProperties();
                }
                serializedObject.ApplyModifiedProperties();
            }
            else
            {
                EditorGUILayout.HelpBox("Settings for this package are unsupported for this target platform.", MessageType.Info);
            }
            EditorGUILayout.EndBuildTargetSelectionGrouping();
        }
Example #15
0
        public override void OnInspectorGUI()
        {
            PlayerIdentityGeneralSettingsPerBuildTarget targetObject;

            if (serializedObject == null || serializedObject.targetObject == null)
            {
                return;
            }

            if (m_MustReloadData)
            {
                ReloadData();
            }

            serializedObject.Update();

            // Load the current settings
            targetObject = serializedObject.targetObject as PlayerIdentityGeneralSettingsPerBuildTarget;
            if (targetObject == null)
            {
                return;
            }
            // Always use standalone for setting identity backend and other global settings
            var standaloneCurrentSettings = targetObject.SettingsForBuildTarget(BuildTargetGroup.Standalone);

            // UI to select backend loader
            GUILayout.Label("Select Identity Backend", EditorStyles.boldLabel);
            EditorGUILayout.BeginHorizontal();
            {
                EditorGUILayout.PrefixLabel("Backend Type");

                var currentSelectedBackendIndex =
                    GetSelectedBackendLoaderIndex(standaloneCurrentSettings, m_AllBackendLoaderInfo);
                currentSelectedBackendIndex =
                    EditorGUILayout.Popup(currentSelectedBackendIndex, GetLoaderNames(m_AllBackendLoaderInfo));
                if (m_AllBackendLoaderInfo.Count > 0)
                {
                    m_SelectedBackendLoaderInfo = m_AllBackendLoaderInfo[currentSelectedBackendIndex];

                    // Apply to all values, not just current setting
                    ApplyChangesToAllSettings((group, currentValue) =>
                    {
                        var localCachedItem = GetOrCreateCachedItem(group, currentValue.objectReferenceValue as PlayerIdentityGeneralSettings);
                        localCachedItem.managerSettingsObject.FindProperty("m_BackendLoader").objectReferenceValue =
                            m_SelectedBackendLoaderInfo.instance;
                        localCachedItem.managerSettingsObject.ApplyModifiedProperties();
                    });
                }
                else
                {
                    m_SelectedBackendLoaderInfo = null;
                }
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.Space();

            // UI to select identity providers
            GUILayout.Label("Configure Identity Providers", EditorStyles.boldLabel);
            var buildTargetGroup = EditorGUILayout.BeginBuildTargetSelectionGrouping();

            {
                var currentSettings = targetObject.SettingsForBuildTarget(buildTargetGroup);
                var cachedItem      = GetOrCreateCachedItem(buildTargetGroup, currentSettings);
                if (cachedItem.loaderOrderUI == null)
                {
                    var loaderList   = FindLoaderList(cachedItem);
                    var loadersInUse = FindLoadersInUse(cachedItem);
                    cachedItem.loaderOrderUI = new LoaderOrderUI(m_AllProviderLoaderInfo, loadersInUse, loaderList,
                                                                 onUpdate: () =>
                    {
                        ReloadData();
                    });
                }

                m_MustReloadData = cachedItem.loaderOrderUI.OnGUI();
                serializedObject.ApplyModifiedProperties();
            }
            EditorGUILayout.EndBuildTargetSelectionGrouping();

            // Options
            // Whether verify email shall be triggered automatically
            standaloneCurrentSettings.Manager.automaticallyVerifyEmail = EditorGUILayout.ToggleLeft("Automatically send verification email to users who sign up with email.", standaloneCurrentSettings.Manager.automaticallyVerifyEmail);

            // Apply to all values
            ApplyChangesToAllSettings((group, currentValue) =>
            {
                var localCachedItem = GetOrCreateCachedItem(group, currentValue.objectReferenceValue as PlayerIdentityGeneralSettings);
                localCachedItem.managerSettingsObject.FindProperty("m_AutomaticallyVerifyEmail").boolValue =
                    standaloneCurrentSettings.Manager.automaticallyVerifyEmail;
                localCachedItem.managerSettingsObject.ApplyModifiedProperties();
            });

            serializedObject.ApplyModifiedProperties();
        }
Example #16
0
        private void DisplayLoaderSelectionUI()
        {
            BuildTargetGroup buildTargetGroup = EditorGUILayout.BeginBuildTargetSelectionGrouping();

            try
            {
                bool buildTargetChanged = m_LastBuildTargetGroup != buildTargetGroup;
                if (buildTargetChanged)
                {
                    m_LastBuildTargetGroup = buildTargetGroup;
                }

                XRGeneralSettings settings = currentSettings.SettingsForBuildTarget(buildTargetGroup);
                if (settings == null)
                {
                    settings = ScriptableObject.CreateInstance <XRGeneralSettings>() as XRGeneralSettings;
                    currentSettings.SetSettingsForBuildTarget(buildTargetGroup, settings);
                    settings.name = $"{buildTargetGroup.ToString()} Settings";
                    AssetDatabase.AddObjectToAsset(settings, AssetDatabase.GetAssetOrScenePath(currentSettings));
                }

                var serializedSettingsObject = new SerializedObject(settings);
                serializedSettingsObject.Update();

                SerializedProperty initOnStart = serializedSettingsObject.FindProperty("m_InitManagerOnStart");
                EditorGUILayout.PropertyField(initOnStart, Content.k_InitializeOnStart);
                EditorGUILayout.Space();

                SerializedProperty loaderProp = serializedSettingsObject.FindProperty("m_LoaderManagerInstance");

                if (!CachedSettingsEditor.ContainsKey(buildTargetGroup))
                {
                    CachedSettingsEditor.Add(buildTargetGroup, null);
                }

                if (loaderProp.objectReferenceValue == null)
                {
                    var xrManagerSettings = ScriptableObject.CreateInstance <XRManagerSettings>() as XRManagerSettings;
                    xrManagerSettings.name = $"{buildTargetGroup.ToString()} Providers";
                    AssetDatabase.AddObjectToAsset(xrManagerSettings, AssetDatabase.GetAssetOrScenePath(currentSettings));
                    loaderProp.objectReferenceValue = xrManagerSettings;
                    serializedSettingsObject.ApplyModifiedProperties();
                }

                var obj = loaderProp.objectReferenceValue;

                if (obj != null)
                {
                    loaderProp.objectReferenceValue = obj;

                    if (CachedSettingsEditor[buildTargetGroup] == null)
                    {
                        CachedSettingsEditor[buildTargetGroup] = Editor.CreateEditor(obj) as XRManagerSettingsEditor;

                        if (CachedSettingsEditor[buildTargetGroup] == null)
                        {
                            Debug.LogError("Failed to create a view for XR Manager Settings Instance");
                        }
                    }

                    if (CachedSettingsEditor[buildTargetGroup] != null)
                    {
                        if (ResetUi)
                        {
                            ResetUi = false;
                            CachedSettingsEditor[buildTargetGroup].Reload();
                        }

                        CachedSettingsEditor[buildTargetGroup].BuildTarget = buildTargetGroup;
                        CachedSettingsEditor[buildTargetGroup].OnInspectorGUI();
                    }
                }
                else if (obj == null)
                {
                    settings.AssignedSettings       = null;
                    loaderProp.objectReferenceValue = null;
                }

                serializedSettingsObject.ApplyModifiedProperties();
            }
            catch (Exception ex)
            {
                Debug.LogError($"Error trying to display plug-in assingment UI : {ex.Message}");
            }

            EditorGUILayout.EndBuildTargetSelectionGrouping();
        }
    protected override void OnGUI()
    {
        base.OnGUI();

        EditorGUILayout.LabelField("ChangeCheck 框选中代码只有被操作后,判断内逻辑才会被执行,而不是每帧执行");
        EditorGUILayout.Space();
        EditorGUI.BeginChangeCheck();
        go = (GameObject)EditorGUILayout.ObjectField(go, typeof(GameObject), true);

        if (EditorGUI.EndChangeCheck())
        {
            Debug.Log("chanegr");
        }

        ///和上述是等价的。
        using (var changerCheck = new EditorGUI.ChangeCheckScope())
        {
            go = (GameObject)EditorGUILayout.ObjectField(go, typeof(GameObject), true);
            if (changerCheck.changed)
            {
                Debug.Log("use changer");
            }
        }


        EditorGUILayout.LabelField("DisabledGroup");
        EditorGUILayout.Space();
        EditorGUI.BeginDisabledGroup(false);
        EditorGUILayout.LabelField("Disable false");
        EditorGUI.EndDisabledGroup();
        EditorGUI.BeginDisabledGroup(true);
        EditorGUILayout.LabelField("Disable true");
        EditorGUI.EndDisabledGroup();

        EditorGUILayout.LabelField("FadeGroup");
        EditorGUILayout.Space();
        m_ShowExtraFields.target = EditorGUILayout.ToggleLeft("Show extra fields", m_ShowExtraFields.target);
        if (EditorGUILayout.BeginFadeGroup(m_ShowExtraFields.faded))
        {
            EditorGUILayout.LabelField("FadeGroup");
            EditorGUILayout.LabelField("FadeGroup");
            EditorGUILayout.LabelField("FadeGroup");
            GUILayout.Button("Btn");
        }

        EditorGUILayout.EndFadeGroup();

        EditorGUILayout.LabelField("ToogleGroup");
        EditorGUILayout.Space();
        toogle = EditorGUILayout.BeginToggleGroup("ToogleGroup", toogle);

        EditorGUILayout.LabelField("ToogleGroup");
        EditorGUILayout.LabelField("ToogleGroup");
        EditorGUILayout.LabelField("ToogleGroup");
        GUILayout.Button("Btn");
        EditorGUILayout.EndToggleGroup();


        EditorGUILayout.LabelField("BuildTargetSelectionGrouping");
        EditorGUILayout.Space();

        target = EditorGUILayout.BeginBuildTargetSelectionGrouping();
        if (target == BuildTargetGroup.Android)
        {
            EditorGUILayout.LabelField("Android specific things");
        }
        if (target == BuildTargetGroup.Standalone)
        {
            EditorGUILayout.LabelField("Standalone specific things");
        }
        EditorGUILayout.EndBuildTargetSelectionGrouping();
    }