UnityEditor.MaterialEditor.PropertiesDefaultGUI C# (CSharp) Method

PropertiesDefaultGUI() public method

public PropertiesDefaultGUI ( MaterialProperty props ) : void
props MaterialProperty
return void
        public void PropertiesDefaultGUI(MaterialProperty[] props)
        {
            this.SetDefaultGUIWidths();
            if (this.m_InfoMessage != null)
            {
                EditorGUILayout.HelpBox(this.m_InfoMessage, MessageType.Info);
            }
            else
            {
                GUIUtility.GetControlID(s_ControlHash, FocusType.Passive, new Rect(0f, 0f, 0f, 0f));
            }
            for (int i = 0; i < props.Length; i++)
            {
                if ((props[i].flags & (MaterialProperty.PropFlags.PerRendererData | MaterialProperty.PropFlags.HideInInspector)) == MaterialProperty.PropFlags.None)
                {
                    float propertyHeight = this.GetPropertyHeight(props[i], props[i].displayName);
                    Rect position = EditorGUILayout.GetControlRect(true, propertyHeight, EditorStyles.layerMaskField, new GUILayoutOption[0]);
                    this.ShaderProperty(position, props[i], props[i].displayName);
                }
            }
        }

Usage Example

        public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] props)
        {
            if (!m_Initialized)
            {
                m_ShowLatLongLayout.valueChanged.AddListener(materialEditor.Repaint);
                m_ShowMirrorOnBack.valueChanged.AddListener(materialEditor.Repaint);
                m_Show3DControl.valueChanged.AddListener(materialEditor.Repaint);

                m_Initialized = true;
            }

            // Allow the default implementation to set widths for consistency for common properties.
            float lw = EditorGUIUtility.labelWidth;

            materialEditor.SetDefaultGUIWidths();

            ShowProp(materialEditor, FindProperty("_Tint", props));
            ShowProp(materialEditor, FindProperty("_Exposure", props));
            ShowProp(materialEditor, FindProperty("_Rotation", props));
            ShowProp(materialEditor, FindProperty("_Tex", props));

            EditorGUIUtility.labelWidth = lw;

            m_ShowLatLongLayout.target = ShowProp(materialEditor, FindProperty("_Mapping", props)) == 1;

            if (EditorGUILayout.BeginFadeGroup(m_ShowLatLongLayout.faded))
            {
                m_ShowMirrorOnBack.target = ShowProp(materialEditor, FindProperty("_ImageType", props)) == 1;

                if (EditorGUILayout.BeginFadeGroup(m_ShowMirrorOnBack.faded))
                {
                    EditorGUI.indentLevel++;

                    ShowProp(materialEditor, FindProperty("_MirrorOnBack", props));

                    EditorGUI.indentLevel--;
                }

                EditorGUILayout.EndFadeGroup();

                // No 3D settings unless PlayerSettings have VR support.
                m_Show3DControl.value = PlayerSettings.virtualRealitySupported;

                if (EditorGUILayout.BeginFadeGroup(m_Show3DControl.faded))
                {
                    ShowProp(materialEditor, FindProperty("_Layout", props));
                }

                EditorGUILayout.EndFadeGroup();
            }

            EditorGUILayout.EndFadeGroup();

            // Let the default implementation add the extra shader properties at the bottom.
            materialEditor.PropertiesDefaultGUI(new MaterialProperty[0]);
        }
All Usage Examples Of UnityEditor.MaterialEditor::PropertiesDefaultGUI
MaterialEditor