Пример #1
0
        protected void VRManagerPackmanCheck()
        {
#if UNITY_EDITOR && UNITY_2019_4_OR_NEWER
            if (packmanRequest.IsCompleted)
            {
                var found = false;
                // On success check if xr management is installed
                if (packmanRequest.Status == UnityEditor.PackageManager.StatusCode.Success)
                {
                    foreach (var package in packmanRequest.Result)
                    {
                        if (package.name.Contains("xr.management"))
                        {
                            found = true;
                        }
                    }
                }

                // Decide wether or not to add define
                if (found)
                {
                    SymbolDefineUtils.AddDefine("SSAA_XR");
                }
                else
                {
                    SymbolDefineUtils.RemoveDefine("SSAA_XR");
                    Debug.LogError("XR Management package not found. SSAA Requires it to be installed on Unity 2019.4+");
                }
                EditorApplication.update -= VRManagerPackmanCheck;
            }
#endif
        }
Пример #2
0
        private void OnEnable()
        {
#if UNITY_EDITOR
#if UNITY_2019_4_OR_NEWER
            // Check for unity XR management package
            packmanRequest            = UnityEditor.PackageManager.Client.List(); // List packages installed for the project
            EditorApplication.update += VRManagerPackmanCheck;
#else
            SymbolDefineUtils.RemoveDefine("SSAA_XR");
#endif
            if (!EditorApplication.isPlaying)
            {
                return;
            }
#endif

            // Handle original scaling
            // Handle the resolution multiplier
            if (!VRDeviceAnyActive())
            {
                throw new Exception("VRDevice not present or not detected");
            }

            // Cache old resolution before using SSAA .This solves issues with more exotic
            // headsets that use non 1x scaling by default such as Playstation VR
            VRDeviceCacheRes();

            // Decide if we initialize or just re-enable
            if (!Initialized)
            {
                Start();
            }
            else if (Pipeline == RenderPipelineUtils.PipelineType.BuiltInPipeline)
            {
                SetupDownsamplerCommandBuffer();
            }

            // Adaptive res startup
            StartCoroutine(UpdateAdaptiveRes());
        }
Пример #3
0
        public virtual void DrawSectionMisc() // General Tab
        {
            #region Extension IPointer Events
            bool extensionIPointerEventsSupport = targetAsSSAA.ExtensionIPointerEvents.IsSupported();
            if (extensionIPointerEventsSupport)
            {
                GUI.color = extensionIPointerEvents.FindPropertyRelative("enabled").boolValue ? new Color(.5f, 1f, .5f) : new Color(.8f, .8f, .8f);
            }
            else
            {
                GUI.color = new Color(1f, .3f, .3f);
            }
            EditorGUILayout.BeginHorizontal(styleHeader);
            {
                GUI.color = Color.white;
                EditorGUI.indentLevel++;
                extensionIPointerEvents.FindPropertyRelative("inspectorFoldout").boolValue = EditorGUILayout.Foldout(
                    extensionIPointerEvents.FindPropertyRelative("inspectorFoldout").boolValue,
                    "Unity IPointerEvents Integration",
                    true,
                    styleFoldout);
                EditorGUI.indentLevel--;
                GUI.color = colorAccentPro;
                if (GUILayout.Button(extensionIPointerEvents.FindPropertyRelative("enabled").boolValue ? "Disable" : "Enable", GUILayout.MaxWidth(100), GUILayout.MinWidth(100)))
                {
                    targetAsSSAA.enabled = false;
                    targetAsSSAA.ExtensionIPointerEvents.enabled = !targetAsSSAA.ExtensionIPointerEvents.enabled;
                    targetAsSSAA.enabled = true;
                }
                GUI.color = Color.white;
            }
            EditorGUILayout.EndHorizontal();
            if (extensionIPointerEvents.FindPropertyRelative("inspectorFoldout").boolValue)
            {
                EditorGUILayout.BeginVertical(styleContentBox);
                EditorGUILayout.HelpBox(SSAAExtensionPointerEventsSupport.description, MessageType.Info);
                EditorGUILayout.PropertyField(extensionIPointerEvents.FindPropertyRelative("eventsLayerMask"));
                EditorGUILayout.EndVertical();
            }
            #endregion

            #region Extension Post Processing Stack 2
            bool extensionPostProcessingStackSupport = targetAsSSAA.ExtensionPostProcessingStack.IsSupported();
            if (extensionPostProcessingStackSupport)
            {
                GUI.color = extensionPostProcessingStack.FindPropertyRelative("enabled").boolValue ? new Color(.5f, 1f, .5f) : new Color(.8f, .8f, .8f);
            }
            else
            {
                GUI.color = new Color(1f, .3f, .3f);
            }
            EditorGUILayout.BeginHorizontal(styleHeader);
            {
                GUI.color = Color.white;
                EditorGUI.indentLevel++;
                extensionPostProcessingStack.FindPropertyRelative("inspectorFoldout").boolValue = EditorGUILayout.Foldout(
                    extensionPostProcessingStack.FindPropertyRelative("inspectorFoldout").boolValue,
                    "Unity PostProcessing Stack V2 Integration",
                    true,
                    styleFoldout);

                EditorGUI.indentLevel--;
                GUI.color = colorAccentPro;
                if (extensionPostProcessingStackSupport)
                {
                    if (GUILayout.Button(extensionPostProcessingStack.FindPropertyRelative("enabled").boolValue ? "Disable" : "Enable", GUILayout.MaxWidth(100), GUILayout.MinWidth(100)))
                    {
                        targetAsSSAA.enabled = false;
                        targetAsSSAA.ExtensionPostProcessingStack.enabled = !targetAsSSAA.ExtensionPostProcessingStack.enabled;
                        targetAsSSAA.enabled = true;
                    }
                }
                GUI.color = Color.white;
            }
            EditorGUILayout.EndHorizontal();
            if (extensionPostProcessingStack.FindPropertyRelative("inspectorFoldout").boolValue)
            {
                EditorGUILayout.BeginVertical(styleContentBox);
                if (extensionPostProcessingStackSupport)
                {
                    EditorGUILayout.HelpBox(SSAAExtensionPostProcessingStack2.description, MessageType.Info);
                    EditorGUILayout.PropertyField(extensionPostProcessingStack.FindPropertyRelative("updateFromOriginal"));
                    EditorGUILayout.PropertyField(extensionPostProcessingStack.FindPropertyRelative("lwrpLegacySupport"));
                }
                else
                {
                    EditorGUILayout.HelpBox(SSAAExtensionPostProcessingStack2.requirement, MessageType.Error);
                }
                EditorGUILayout.EndVertical();
            }
            #endregion

            #region Extension Cinemachine
            bool extensionCinemachineSupport = targetAsSSAA.ExtensionCinemachine.IsSupported();
            if (extensionCinemachineSupport)
            {
                GUI.color = extensionCinemachine.FindPropertyRelative("enabled").boolValue ? new Color(.5f, 1f, .5f) : new Color(.8f, .8f, .8f);
            }
            else
            {
                GUI.color = new Color(1f, .3f, .3f);
            }
            EditorGUILayout.BeginHorizontal(styleHeader);
            {
                GUI.color = Color.white;
                EditorGUI.indentLevel++;
                extensionCinemachine.FindPropertyRelative("inspectorFoldout").boolValue = EditorGUILayout.Foldout(
                    extensionCinemachine.FindPropertyRelative("inspectorFoldout").boolValue,
                    "Unity Cinemachine Integration",
                    true,
                    styleFoldout);

                EditorGUI.indentLevel--;
                GUI.color = colorAccentPro;
                if (extensionCinemachineSupport)
                {
                    if (GUILayout.Button(extensionCinemachine.FindPropertyRelative("enabled").boolValue ? "Disable" : "Enable", GUILayout.MaxWidth(100), GUILayout.MinWidth(100)))
                    {
                        targetAsSSAA.enabled = false;
                        targetAsSSAA.ExtensionCinemachine.enabled = !targetAsSSAA.ExtensionCinemachine.enabled;
                        if (targetAsSSAA.ExtensionCinemachine.enabled)
                        {
                            SymbolDefineUtils.AddDefine("SSAA_CINEMACHINE");
                        }
                        else
                        {
                            SymbolDefineUtils.RemoveDefine("SSAA_CINEMACHINE");
                        }
                        targetAsSSAA.enabled = true;
                    }
                }
                GUI.color = Color.white;
            }
            EditorGUILayout.EndHorizontal();
            if (extensionCinemachine.FindPropertyRelative("inspectorFoldout").boolValue)
            {
                EditorGUILayout.BeginVertical(styleContentBox);
                if (extensionCinemachineSupport)
                {
                    EditorGUILayout.HelpBox(SSAAExtensionCinemachine.description, MessageType.Info);
                    EditorGUILayout.PropertyField(extensionCinemachine.FindPropertyRelative("updateFromOriginal"));
                }
                else
                {
                    EditorGUILayout.HelpBox(SSAAExtensionCinemachine.requirement, MessageType.Error);
                }
                EditorGUILayout.EndVertical();
            }
            #endregion

            // Draw Extensions
            EditorMacros.DrawHeader("Misc", styleHeader);
            EditorGUI.indentLevel++;
            EditorGUILayout.BeginVertical(styleContentBox);
            // Handle render texture precision mode
            if (!Application.isPlaying)
            {
                currentMode = internalTextureFormat.enumValueIndex == (int)RenderTextureFormat.ARGBFloat ? TextureMode.Float : TextureMode.Half;
                var oldMode = currentMode;
                currentMode = (TextureMode)EditorGUILayout.EnumPopup(new GUIContent("Render Texture Precision"), currentMode);
                internalTextureFormat.enumValueIndex = currentMode == TextureMode.Half ? (int)RenderTextureFormat.ARGBHalf : (int)RenderTextureFormat.ARGBFloat;
                if (oldMode != currentMode)
                {
                    targetAsSSAA.Refresh();
                }
            }
            EditorGUILayout.PropertyField(inspectorShowHelp);
            EditorGUILayout.Separator();
            EditorGUI.indentLevel--;
            if (GUILayout.Button("Open online documentation"))
            {
                Application.OpenURL("https://github.com/MadGoat-Studio/MadGoat-SSAA-Resolution-Scale/wiki");
            }

            EditorGUILayout.EndVertical();

            // Draw Social Media
            EditorMacros.DrawSocial(styleHeader, styleContentBox);
        }