Exemple #1
0
        /// <summary>
        /// Implement this function to make a custom inspector.
        /// </summary>
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            //================
            // Basic properties.
            //================
            EditorGUILayout.PropertyField(serializedObject.FindProperty("m_Texture"));
            EditorGUILayout.PropertyField(serializedObject.FindProperty("m_Color"));
            EditorGUILayout.PropertyField(serializedObject.FindProperty("m_RaycastTarget"));

            //================
            // Capture effect.
            //================
            GUILayout.Space(10);
            EditorGUILayout.LabelField("Capture Effect", EditorStyles.boldLabel);
            UIEffectEditor.DrawEffectProperties(UIEffectCapturedImage.shaderName, serializedObject);

            //================
            // Advanced option.
            //================
            GUILayout.Space(10);
            EditorGUILayout.LabelField("Advanced Option", EditorStyles.boldLabel);

            // Desampling rate.
            DrawDesamplingRate(serializedObject.FindProperty("m_DesamplingRate"));

            // Reduction rate.
            DrawDesamplingRate(serializedObject.FindProperty("m_ReductionRate"));

            // Filter Mode.
            EditorGUILayout.PropertyField(serializedObject.FindProperty("m_FilterMode"));

            serializedObject.ApplyModifiedProperties();

            // Debug.
            using (new EditorGUILayout.HorizontalScope(EditorStyles.helpBox))
            {
                GUILayout.Label("Debug");

                if (GUILayout.Button("Capture", "ButtonLeft"))
                {
                    UpdateTexture(true);
                }

                EditorGUI.BeginDisabledGroup(!(target as UIEffectCapturedImage).capturedTexture);
                if (GUILayout.Button("Release", "ButtonRight"))
                {
                    UpdateTexture(false);
                }
                EditorGUI.EndDisabledGroup();
            }
        }
        /// <summary>
        /// Implement this function to make a custom inspector.
        /// </summary>
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            //================
            // Basic properties.
            //================
            EditorGUILayout.PropertyField(_spTexture);
            EditorGUILayout.PropertyField(_spColor);
            EditorGUILayout.PropertyField(_spRaycastTarget);

            //================
            // Capture effect.
            //================
            GUILayout.Space(10);
            EditorGUILayout.LabelField("Capture Effect", EditorStyles.boldLabel);
            UIEffectEditor.DrawEffectProperties(UIEffectCapturedImage.shaderName, serializedObject);

            //================
            // Advanced option.
            //================
            GUILayout.Space(10);
            EditorGUILayout.LabelField("Advanced Option", EditorStyles.boldLabel);

            EditorGUI.BeginChangeCheck();
            QualityMode quality = qualityMode;

            quality = (QualityMode)EditorGUILayout.EnumPopup("Quality Mode", quality);
            if (EditorGUI.EndChangeCheck())
            {
                _customAdvancedOption = (quality == QualityMode.Custom) || _spTargetTexture.objectReferenceValue;
                qualityMode           = quality;
            }

            // When qualityMode is `Custom`, show advanced option.
            if (_customAdvancedOption)
            {
                if (_spBlurMode.intValue != 0)
                {
                    EditorGUILayout.PropertyField(_spIterations);       // Iterations.
                }
                EditorGUILayout.PropertyField(_spKeepSizeToRootCanvas); // Keep Graphic Size To RootCanvas.
                DrawDesamplingRate(_spReductionRate);                   // Reduction rate.

                EditorGUILayout.Space();
                EditorGUILayout.LabelField("Result Texture Setting", EditorStyles.boldLabel);

                if (!_spTargetTexture.objectReferenceValue)
                {
                    EditorGUILayout.PropertyField(_spFilterMode);             // Filter Mode.
                    DrawDesamplingRate(_spDesamplingRate);                    // Desampling rate.
                }
                using (new EditorGUILayout.HorizontalScope())
                {
                    EditorGUILayout.PropertyField(_spTargetTexture);                    // Target Texture.
                    Texture t = _spTargetTexture.objectReferenceValue as Texture;
                    if (t)
                    {
                        GUILayout.Label(string.Format("{0}x{1}", t.width, t.height), EditorStyles.miniLabel);
                    }
                }
            }

            serializedObject.ApplyModifiedProperties();

            // Debug.
            using (new EditorGUILayout.HorizontalScope(EditorStyles.helpBox))
            {
                GUILayout.Label("Debug");

                if (GUILayout.Button("Capture", "ButtonLeft"))
                {
                    UpdateTexture(true);
                }

                EditorGUI.BeginDisabledGroup(!(target as UIEffectCapturedImage).capturedTexture);
                if (GUILayout.Button("Release", "ButtonRight"))
                {
                    UpdateTexture(false);
                }
                EditorGUI.EndDisabledGroup();
            }

            // Warning message for overlay rendering.
            var graphic = (target as UIEffectCapturedImage);

            if (graphic && graphic.canvas)
            {
                var canvas = graphic.canvas.rootCanvas;
                if (canvas && canvas.renderMode != RenderMode.ScreenSpaceCamera)
                {
                    using (new GUILayout.HorizontalScope())
                    {
                        EditorGUILayout.HelpBox("'ScreenSpace - Overlay' and 'WorldSpace - Camera' render modes are not supported. Change render mode of root canvas to 'ScreenSpace - Camera'.", MessageType.Warning);
                        if (GUILayout.Button("Canvas"))
                        {
                            Selection.activeGameObject = canvas.gameObject;
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Implement this function to make a custom inspector.
        /// </summary>
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            //================
            // Basic properties.
            //================
            EditorGUILayout.PropertyField(_spTexture);
            EditorGUILayout.PropertyField(_spColor);
            EditorGUILayout.PropertyField(_spRaycastTarget);

            //================
            // Capture effect.
            //================
            GUILayout.Space(10);
            EditorGUILayout.LabelField("Capture Effect", EditorStyles.boldLabel);
            UIEffectEditor.DrawEffectProperties(UIEffectCapturedImage.shaderName, serializedObject);

            //================
            // Advanced option.
            //================
            GUILayout.Space(10);
            EditorGUILayout.LabelField("Advanced Option", EditorStyles.boldLabel);

            EditorGUI.BeginChangeCheck();
            QualityMode quality = qualityMode;

            quality = (QualityMode)EditorGUILayout.EnumPopup("Quality Mode", quality);
            if (EditorGUI.EndChangeCheck())
            {
                _customAdvancedOption = (quality == QualityMode.Custom);
                qualityMode           = quality;
            }

            // When qualityMode is `Custom`, show advanced option.
            if (_customAdvancedOption)
            {
                DrawDesamplingRate(_spDesamplingRate);               // Desampling rate.
                DrawDesamplingRate(_spReductionRate);                // Reduction rate.
                EditorGUILayout.PropertyField(_spFilterMode);        // Filter Mode.
                EditorGUILayout.PropertyField(_spIterations);        // Iterations.
            }
            EditorGUILayout.PropertyField(_spKeepSizeToRootCanvas);  // Iterations.

            serializedObject.ApplyModifiedProperties();

            // Debug.
            using (new EditorGUILayout.HorizontalScope(EditorStyles.helpBox))
            {
                GUILayout.Label("Debug");

                if (GUILayout.Button("Capture", "ButtonLeft"))
                {
                    UpdateTexture(true);
                }

                EditorGUI.BeginDisabledGroup(!(target as UIEffectCapturedImage).capturedTexture);
                if (GUILayout.Button("Release", "ButtonRight"))
                {
                    UpdateTexture(false);
                }
                EditorGUI.EndDisabledGroup();
            }
        }