예제 #1
0
        void DrawAdvancedOptions(MaterialEditor materialEditor)
        {
            // Get Material
            var material = materialEditor.target as Material;

            // Reflections
            if (material.HasProperty(PropertyNames.EnvironmentReflections))
            {
                materialEditor.ShaderProperty(m_EnvironmentReflectionsProp, Styles.EnvironmentReflections);
            }

            materialEditor.EnableInstancingField();

            // RenderQueue
            if (material.HasProperty(PropertyNames.RenderQueue))
            {
                EditorGUI.BeginChangeCheck();
                var RenderQueue = EditorGUILayout.IntSlider(Styles.RenderQueue, (int)m_RenderQueueProp.floatValue, -1, 5000);
                if (EditorGUI.EndChangeCheck())
                {
                    m_RenderQueueProp.floatValue = RenderQueue;
                }
                material.renderQueue = (int)m_RenderQueueProp.floatValue;
            }
        }
예제 #2
0
 protected void DoMaterialRenderingOptions()
 {
     EditorGUILayout.Space();
     GUILayout.Label(Styles.renderingOptionsLabel, EditorStyles.boldLabel);
     m_MaterialEditor.EnableInstancingField();
     m_MaterialEditor.DoubleSidedGIField();
 }
    private void ShaderProperties()
    {
        MaterialProperty mainTex = FindProperty("_MainTex");

        editor.TexturePropertySingleLine(MakeLabel("Base Map", "Specify the base color(RGB) and opacity(A)."), mainTex, FindProperty("_Color"));
        ReticleProperties();

        MaterialProperty isViewmodel = FindProperty("_Viewmodel");

        EditorGUI.BeginChangeCheck();
        editor.ShaderProperty(isViewmodel, MakeLabel(isViewmodel));

        if (Math.Abs(isViewmodel.floatValue - 1) < Mathf.Epsilon)
        {
            EditorGUI.indentLevel += 1;
            editor.ShaderProperty(FindProperty("_ViewmodelFOV"), MakeLabel("Field of View"));
            EditorGUI.indentLevel -= 1;
        }

        if (EditorGUI.EndChangeCheck())
        {
            SetKeyword("_VIEWMODEL", Math.Abs(isViewmodel.floatValue - 1) < Mathf.Epsilon);
        }

        editor.EnableInstancingField();
    }
        protected void AdvancedOptions(MaterialEditor materialEditor, Material material)
        {
            EditorGUILayout.Space();
            GUILayout.Label(Styles.advancedOptionsTitle, EditorStyles.boldLabel, new GUILayoutOption[0]);

            EditorGUI.BeginChangeCheck();

            materialEditor.ShaderProperty(renderQueueOverride, Styles.renderQueueOverride);

            if (EditorGUI.EndChangeCheck())
            {
                MaterialChanged(material);
            }

            // Show the RenderQueueField but do not allow users to directly manipulate it. That is done via the renderQueueOverride.
            GUI.enabled = false;
            materialEditor.RenderQueueField();

            // When round corner or border light features are used, enable instancing to disable batching. Static and dynamic
            // batching will normalize the object scale, which breaks border related features.
            GUI.enabled = !PropertyEnabled(roundCorners) && !PropertyEnabled(borderLight);

            if (!GUI.enabled && !material.enableInstancing)
            {
                material.enableInstancing = true;
            }

            materialEditor.EnableInstancingField();
        }
예제 #5
0
        public void ShaderPropertiesGUI(Material material)
        {
            // Use default labelWidth
            EditorGUIUtility.labelWidth = 0f;

            // Detect any changes to the material
            EditorGUI.BeginChangeCheck();
            {
                BaseMaterialPropertiesGUI();
                EditorGUILayout.Space();

                VertexAnimationPropertiesGUI();

                EditorGUILayout.Space();
                MaterialPropertiesGUI(material);

                DoEmissionArea(material);
                m_MaterialEditor.EnableInstancingField();
            }

            if (EditorGUI.EndChangeCheck())
            {
                foreach (var obj in m_MaterialEditor.targets)
                {
                    SetupMaterialKeywordsAndPassInternal((Material)obj);
                }
            }
        }
        protected override void DrawPipeline(MaterialEditor materialEditor)
        {
            DrawPipelineHeader();

            materialEditor.EnableInstancingField();
            DrawRenderPriority(materialEditor);
        }
예제 #7
0
        public virtual void ShaderPropertiesGUI(Material material)
        {
            // Use default labelWidth
            EditorGUIUtility.labelWidth = 0f;

            // Detect any changes to the material
            EditorGUI.BeginChangeCheck();
            {
                using (var header = new HeaderScope(StylesBaseUnlit.optionText, (uint)Expandable.Base, this))
                {
                    if (header.expanded)
                    {
                        BaseMaterialPropertiesGUI();
                    }
                }
                VertexAnimationPropertiesGUI();
                MaterialPropertiesGUI(material);
                using (var header = new HeaderScope(StylesBaseUnlit.advancedText, (uint)Expandable.Advance, this))
                {
                    if (header.expanded)
                    {
                        m_MaterialEditor.EnableInstancingField();
                        MaterialPropertiesAdvanceGUI(material);
                    }
                }
            }

            if (EditorGUI.EndChangeCheck())
            {
                foreach (var obj in m_MaterialEditor.targets)
                {
                    SetupMaterialKeywordsAndPassInternal((Material)obj);
                }
            }
        }
예제 #8
0
        protected void AdvancedOptions(MaterialEditor materialEditor, Material material)
        {
            EditorGUILayout.Space();
            GUILayout.Label(Styles.advancedOptionsTitle, EditorStyles.boldLabel, new GUILayoutOption[0]);

            EditorGUI.BeginChangeCheck();

            materialEditor.ShaderProperty(renderQueueOverride, Styles.renderQueueOverride);

            if (EditorGUI.EndChangeCheck())
            {
                MaterialChanged(material);
            }

            // Show the RenderQueueField but do not allow users to directly manipulate it. That is done via the renderQueueOverride.
            GUI.enabled = false;
            materialEditor.RenderQueueField();

            if (!GUI.enabled && !material.enableInstancing)
            {
                material.enableInstancing = true;
            }

            materialEditor.EnableInstancingField();
        }
예제 #9
0
        public void ShaderPropertiesGUI(Material material)
        {
            // Use default labelWidth
            EditorGUIUtility.labelWidth = 0f;

            // Detect any changes to the material
            EditorGUI.BeginChangeCheck();
            {
                BlendModePopup();

                // Primary properties
                GUILayout.Label(Styles.primaryMapsText, EditorStyles.boldLabel);
                DoAlbedoArea(material);
                DoSpecularMetallicArea();
                DoNormalArea();
                m_MaterialEditor.TexturePropertySingleLine(Styles.heightMapText, heightMap, heightMap.textureValue != null ? heigtMapScale : null);
                m_MaterialEditor.TexturePropertySingleLine(Styles.occlusionText, occlusionMap, occlusionMap.textureValue != null ? occlusionStrength : null);
                m_MaterialEditor.TexturePropertySingleLine(Styles.detailMaskText, detailMask);
                DoEmissionArea(material);
                EditorGUI.BeginChangeCheck();
                m_MaterialEditor.TextureScaleOffsetProperty(albedoMap);
                if (EditorGUI.EndChangeCheck())
                {
                    emissionMap.textureScaleAndOffset = albedoMap.textureScaleAndOffset; // Apply the main texture scale and offset to the emission texture as well, for Enlighten's sake
                }
                EditorGUILayout.Space();

                // Secondary properties
                GUILayout.Label(Styles.secondaryMapsText, EditorStyles.boldLabel);
                m_MaterialEditor.TexturePropertySingleLine(Styles.detailAlbedoText, detailAlbedoMap);
                m_MaterialEditor.TexturePropertySingleLine(Styles.detailNormalMapText, detailNormalMap, detailNormalMapScale);
                m_MaterialEditor.TextureScaleOffsetProperty(detailAlbedoMap);
                m_MaterialEditor.ShaderProperty(uvSetSecondary, Styles.uvSetLabel.text);

                // Third properties
                GUILayout.Label(Styles.forwardText, EditorStyles.boldLabel);
                if (highlights != null)
                {
                    m_MaterialEditor.ShaderProperty(highlights, Styles.highlightsText);
                }
                if (reflections != null)
                {
                    m_MaterialEditor.ShaderProperty(reflections, Styles.reflectionsText);
                }
            }
            if (EditorGUI.EndChangeCheck())
            {
                foreach (var obj in blendMode.targets)
                {
                    MaterialChanged((Material)obj, m_WorkflowMode);
                }
            }

            EditorGUILayout.Space();

            // NB renderqueue editor is not shown on purpose: we want to override it based on blend mode
            GUILayout.Label(Styles.advancedText, EditorStyles.boldLabel);
            m_MaterialEditor.EnableInstancingField();
            m_MaterialEditor.DoubleSidedGIField();
        }
예제 #10
0
        public void ShaderPropertiesGUI(Material material)
        {
            // Use default labelWidth
            EditorGUIUtility.labelWidth = 0f;

            // Detect any changes to the material
            EditorGUI.BeginChangeCheck();
            {
                //EditorGUI.indentLevel++;
                BaseMaterialPropertiesGUI();
                EditorGUILayout.Space();

                VertexAnimationPropertiesGUI();

                EditorGUILayout.Space();
                MaterialPropertiesGUI(material);

                DoEmissionArea(material);

                EditorGUILayout.Space();
                EditorGUILayout.LabelField(StylesBaseUnlit.advancedText, EditorStyles.boldLabel);
                // NB RenderQueue editor is not shown on purpose: we want to override it based on blend mode
                EditorGUI.indentLevel++;
                m_MaterialEditor.EnableInstancingField();
                EditorGUI.indentLevel--;
            }

            if (EditorGUI.EndChangeCheck())
            {
                foreach (var obj in m_MaterialEditor.targets)
                {
                    SetupMaterialKeywordsAndPassInternal((Material)obj);
                }
            }
        }
예제 #11
0
        //https://github.com/Unity-Technologies/ScriptableRenderPipeline/blob/648184ec8405115e2fcf4ad3023d8b16a191c4c7/com.unity.render-pipelines.universal/Editor/ShaderGUI/BaseShaderGUI.cs
        public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] props)
        {
            this.materialEditor = materialEditor;

            materialEditor.SetDefaultGUIWidths();
            materialEditor.UseDefaultMargins();
            EditorGUIUtility.labelWidth = 0f;

            targetMat = materialEditor.target as Material;
            keyWords  = targetMat.shaderKeywords;

            FindProperties(props);

            //base.OnGUI(materialEditor, props);
            //return;

            EditorGUILayout.LabelField(AssetInfo.ASSET_NAME + " " + AssetInfo.INSTALLED_VERSION, EditorStyles.centeredGreyMiniLabel);
            EditorGUILayout.Space();

            EditorGUI.BeginChangeCheck();

            using (new EditorGUILayout.HorizontalScope())
            {
                EditorGUILayout.LabelField("Lighting", GUILayout.Width(EditorGUIUtility.labelWidth));
                advancedLighting.floatValue = (float)GUILayout.Toolbar((int)advancedLighting.floatValue,
                                                                       new GUIContent[] { simpleLightingContent, advancedLightingContent }
                                                                       );
            }
            EditorGUILayout.Space();

            DrawRendering();
            EditorGUILayout.Space();
            DrawMaps();
            EditorGUILayout.Space();
            DrawColor();
            EditorGUILayout.Space();
            DrawShading();
            EditorGUILayout.Space();
            DrawBending();
            EditorGUILayout.Space();
            DrawWind();

            EditorGUILayout.Space();

            materialEditor.EnableInstancingField();
            if (!materialEditor.IsInstancingEnabled())
            {
                EditorGUILayout.HelpBox("GPU Instancing is highly recommended for optimal performance", MessageType.Warning);
            }
            materialEditor.RenderQueueField();
            materialEditor.DoubleSidedGIField();

            if (EditorGUI.EndChangeCheck())
            {
                ApplyChanges();
            }

            EditorGUILayout.Space();
            EditorGUILayout.LabelField("- Staggart Creations -", EditorStyles.centeredGreyMiniLabel);
        }
        private void DrawMaterialOptions(MaterialEditor editor, Material mat)
        {
            var advState = EditorGUILayout.BeginFoldoutHeaderGroup(GetToggleState("Advanced"), Styles.OptionsHeaderContent);

            if (advState)
            {
                {
                    int vmMode = mat.GetInt("_ViewModel");
                    var t      = EditorGUILayout.Toggle(Styles.ViewmodelModeContent, vmMode > 0);
                    mat.SetInt("_ViewModel", t ? 1 : 0);
                }

                editor.EnableInstancingField();

                if (emissiveTex.textureValue == null)
                {
                    EditorGUILayout.HelpBox(Styles.EmissiveNoticeContent.text, MessageType.Warning);
                }
                EditorGUI.BeginDisabledGroup(emissiveTex.textureValue == null);
                {
                    editor.LightmapEmissionProperty();
                    editor.DoubleSidedGIField();
                }
                EditorGUI.EndDisabledGroup();
            }

            SetToggleState("Advanced", advState);
            EditorGUILayout.EndFoldoutHeaderGroup();
        }
예제 #13
0
    public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] props)
    {
        FindProperties(props); // MaterialProperties can be animated so we do not cache them but fetch them every event to ensure animated values are updated correctly
        m_MaterialEditor = materialEditor;
        Material material = materialEditor.target as Material;

        // Make sure that needed setup (ie keywords/renderqueue) are set up if we're switching some existing
        // material to a standard shader.
        // Do this before any GUI code has been issued to prevent layout issues in subsequent GUILayout statements (case 780071)
        if (m_FirstTimeApply)
        {
            MaterialChanged(material, m_WorkflowMode);
            m_FirstTimeApply = false;
        }

        ShaderPropertiesGUI(material);

#if UNITY_5_5_OR_NEWER
        materialEditor.RenderQueueField();
#endif
#if UNITY_5_6_OR_NEWER
        materialEditor.EnableInstancingField();
#endif
        GUILayout.EndVertical();
    }
예제 #14
0
    private void ShaderProperties()
    {
        EditorUtilities.FoldoutHeader("Surface Inputs", ref surfaceInputs);

        if (surfaceInputs)
        {
            EditorGUI.indentLevel += 1;
            MaterialProperty mainTex = FindProperty("_BaseColorMap");
            editor.TexturePropertySingleLine(MakeLabel("Base Map", "Specify the base color(RGB) and opacity(A)."), mainTex, FindProperty("_BaseColor"));

            MaskProperties();
            NormalProperties();

            editor.TextureScaleOffsetProperty(mainTex);
            EditorGUI.indentLevel -= 1;
        }

        EditorUtilities.FoldoutHeader("Detail Inputs", ref detailInputs);

        if (detailInputs)
        {
            EditorGUI.indentLevel += 1;
            DetailProperties();
            EditorGUI.indentLevel -= 1;
        }

        EditorUtilities.FoldoutHeader("Emission Inputs", ref emissionInputs);

        if (emissionInputs)
        {
            EditorGUI.indentLevel += 1;
            EmissionProperties();
            EditorGUI.indentLevel -= 1;
        }

        EditorUtilities.FoldoutHeader("Advanced Options", ref advancedOptions);

        if (advancedOptions)
        {
            MaterialProperty isViewmodel = FindProperty("_Viewmodel");

            EditorGUI.BeginChangeCheck();
            editor.ShaderProperty(isViewmodel, MakeLabel(isViewmodel));

            if (Math.Abs(isViewmodel.floatValue - 1) < Mathf.Epsilon)
            {
                EditorGUI.indentLevel += 1;
                editor.ShaderProperty(FindProperty("_ViewmodelFOV"), MakeLabel("Field of View"));
                EditorGUI.indentLevel -= 1;
            }

            if (EditorGUI.EndChangeCheck())
            {
                SetKeyword("_VIEWMODEL", Math.Abs(isViewmodel.floatValue - 1) < Mathf.Epsilon);
            }

            editor.EnableInstancingField();
        }
    }
예제 #15
0
 /// <summary>
 /// Shows Queue, instancing and doublesided GI
 /// </summary>
 /// <param name="me"></param>
 protected void ShowAdvancedOptions(MaterialEditor me)
 {
     GUILayout.Space(30);
     EditorGUILayout.LabelField("Advanced Options", EditorStyles.boldLabel);
     me.RenderQueueField();
     me.EnableInstancingField();
     me.DoubleSidedGIField();
 }
 void DrawAdvancedOptions()
 {
     EditorGUILayout.Space();
     GUILayout.Label("Advanced Options", EditorStyles.boldLabel);
     m_MaterialEditor.EnableInstancingField();
     m_MaterialEditor.RenderQueueField();
     m_MaterialEditor.DoubleSidedGIField();
 }
예제 #17
0
 protected static void AdvancedOptionsGUI(MaterialEditor materialEditor)
 {
     EditorGUILayout.Space();
     EditorGUILayout.LabelField("Advanced Options", EditorStyles.boldLabel);
     materialEditor.RenderQueueField();
     materialEditor.EnableInstancingField();
     materialEditor.DoubleSidedGIField();
 }
예제 #18
0
        protected void AdvancedOptions(MaterialEditor materialEditor, Material material)
        {
            EditorGUILayout.Space();
            GUILayout.Label(Styles.advancedOptionsTitle, EditorStyles.boldLabel);

            EditorGUI.BeginChangeCheck();

            materialEditor.ShaderProperty(renderQueueOverride, Styles.renderQueueOverride);

            if (EditorGUI.EndChangeCheck())
            {
                MaterialChanged(material);
            }

            // Show the RenderQueueField but do not allow users to directly manipulate it. That is done via the renderQueueOverride.
            GUI.enabled = false;
            materialEditor.RenderQueueField();

            // When round corner or border light features are used, enable instancing to disable batching. Static and dynamic
            // batching will normalize the object scale, which breaks border related features.
            GUI.enabled = !PropertyEnabled(roundCorners) && !PropertyEnabled(borderLight);

            if (!GUI.enabled && !material.enableInstancing)
            {
                material.enableInstancing = true;
            }

            materialEditor.EnableInstancingField();

            if (material.enableInstancing)
            {
                GUI.enabled = true;
                materialEditor.ShaderProperty(instancedColor, Styles.instancedColor, 2);
            }
            else
            {
                // When instancing is disable, disable instanced color.
                SetFloatProperty(material, Styles.instancedColorFeatureName, Styles.instancedColorName, 0.0f);
            }

            materialEditor.ShaderProperty(stencil, Styles.stencil);

            if (PropertyEnabled(stencil))
            {
                materialEditor.ShaderProperty(stencilReference, Styles.stencilReference, 2);
                materialEditor.ShaderProperty(stencilComparison, Styles.stencilComparison, 2);
                materialEditor.ShaderProperty(stencilOperation, Styles.stencilOperation, 2);
            }
            else
            {
                // When stencil is disable, revert to the default stencil operations. Note, when tested on D3D11 hardware the stencil state
                // is still set even when the CompareFunction.Disabled is selected, but this does not seem to affect performance.
                material.SetInt(Styles.stencilComparisonName, (int)CompareFunction.Disabled);
                material.SetInt(Styles.stencilOperationName, (int)StencilOp.Keep);
            }
        }
예제 #19
0
        /// <summary>If the supported Unity version is used, a field for setting the Render Queue and GPU Instancing options is drawn</summary>
        public static void DrawExtraFields(MaterialEditor m_MaterialEditor)
        {
            #if UNITY_5_5_OR_NEWER
            m_MaterialEditor.RenderQueueField();
            #endif

            #if UNITY_5_6_OR_NEWER
            m_MaterialEditor.EnableInstancingField();
            #endif
        }
    public override void OnGUI(MaterialEditor editor, MaterialProperty[] properties)
    {
        foreach (var property in properties)
        {
            bool hideInInspector = (property.flags & MaterialProperty.PropFlags.HideInInspector) != 0;
            if (hideInInspector)
            {
                continue;
            }

            var tooltip = Tooltips.Get(editor, property.displayName);

            if (property.displayName.Contains("[Header]"))
            {
                DrawHeader(property, tooltip);
                continue;
            }

            if (property.displayName.Contains("[Space]"))
            {
                EditorGUILayout.Space();
                continue;
            }

            var displayName = property.displayName;
            displayName = HandleTabs(displayName);
            displayName = RemoveEverythingInBrackets(displayName);

            if (property.type == MaterialProperty.PropType.Texture && property.name.Contains("GradientTexture"))
            {
                EditorGUILayout.Space(18);
                _gradientDrawer.OnGUI(Rect.zero, property, property.displayName, editor, tooltip);
            }
            else if (property.type == MaterialProperty.PropType.Vector &&
                     property.displayName.Contains("[Vector2]"))
            {
                EditorGUILayout.Space(18);
                _vectorDrawer.OnGUI(Rect.zero, property, displayName, editor, tooltip);
            }
            else
            {
                var guiContent = new GUIContent(displayName, tooltip);
                editor.ShaderProperty(property, guiContent);
            }
        }

        EditorGUILayout.Space();
        EditorGUILayout.Space();
        if (SupportedRenderingFeatures.active.editableMaterialRenderQueue)
        {
            editor.RenderQueueField();
        }
        editor.EnableInstancingField();
        editor.DoubleSidedGIField();
    }
예제 #21
0
파일: LayeredLitUI.cs 프로젝트: sjb8100/SRP
        public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] props)
        {
            FindBaseMaterialProperties(props);
            FindMaterialProperties(props);

            m_MaterialEditor = materialEditor;
            // We should always do this call at the beginning
            m_MaterialEditor.serializedObject.Update();

            Material      material         = m_MaterialEditor.target as Material;
            AssetImporter materialImporter = AssetImporter.GetAtPath(AssetDatabase.GetAssetPath(material.GetInstanceID()));

            InitializeMaterialLayers(materialImporter, ref m_MaterialLayers);

            bool optionsChanged = false;

            EditorGUI.BeginChangeCheck();
            {
                BaseMaterialPropertiesGUI();
                EditorGUILayout.Space();

                VertexAnimationPropertiesGUI();
                EditorGUILayout.Space();
            }
            if (EditorGUI.EndChangeCheck())
            {
                optionsChanged = true;
            }

            bool layerChanged = DoLayersGUI(materialImporter);

            EditorGUILayout.Space();
            GUILayout.Label(Styles.lightingText, EditorStyles.boldLabel);
            EditorGUI.indentLevel++;
            m_MaterialEditor.TexturePropertySingleLine(Styles.emissiveText, emissiveColorMap, emissiveColor);
            m_MaterialEditor.ShaderProperty(emissiveIntensity, Styles.emissiveIntensityText);
            DoEmissionArea(material);
            EditorGUI.indentLevel--;
            m_MaterialEditor.EnableInstancingField();

            if (layerChanged || optionsChanged)
            {
                foreach (var obj in m_MaterialEditor.targets)
                {
                    SetupMaterialKeywordsAndPassInternal((Material)obj);
                }

                // SaveAssetsProcessor the referenced material in the users data
                SaveMaterialLayers(materialImporter);
            }

            // We should always do this call at the end
            m_MaterialEditor.serializedObject.ApplyModifiedProperties();
        }
예제 #22
0
        public void ShaderPropertiesGUI(Material material)
        {
            EditorGUIUtility.labelWidth = 0f; // Use default labelWidth

            EditorGUI.BeginChangeCheck();
            {
                DoBlendModeArea();

                // Primary properties
                GUILayout.Label(Styles.primaryPropertiesText, EditorStyles.boldLabel);
                DoAlbedoArea(material);
                DoSpecularArea();
                DoSubsurfaceArea();
                DoNormalArea();
                DoOcclusionArea();
                DoEmissionArea(material);
                EditorGUI.BeginChangeCheck();
                m_MaterialEditor.TextureScaleOffsetProperty(albedoMap);
                if (EditorGUI.EndChangeCheck())
                {
                    emissionMap.textureScaleAndOffset = albedoMap.textureScaleAndOffset; // Apply the main texture scale and offset to the emission texture as well, for Enlighten's sake
                }
                EditorGUILayout.Space();

                // Rendering properties
                GUILayout.Label(Styles.renderingOptionsText, EditorStyles.boldLabel);
                if (fresnel != null)
                {
                    DoFresnelArea();
                }
                if (highlights != null)
                {
                    m_MaterialEditor.ShaderProperty(highlights, Styles.highlightsText);
                }
                if (reflections != null)
                {
                    m_MaterialEditor.ShaderProperty(reflections, Styles.reflectionsText);
                }
            }
            if (EditorGUI.EndChangeCheck())
            {
                foreach (var obj in blendMode.targets)
                {
                    MaterialChanged((Material)obj);
                }
            }

            EditorGUILayout.Space();

            GUILayout.Label(Styles.advancedText, EditorStyles.boldLabel);
            m_MaterialEditor.RenderQueueField();
            m_MaterialEditor.EnableInstancingField();
            m_MaterialEditor.DoubleSidedGIField();
        }
    public void PropertiesDefaultGUI(MaterialEditor materialEditor)
    {
        var f = materialEditor.GetType().GetField("m_InfoMessage", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);

        if (f != null)
        {
            string m_InfoMessage = (string)f.GetValue(materialEditor);
            materialEditor.SetDefaultGUIWidths();
            if (m_InfoMessage != null)
            {
                EditorGUILayout.HelpBox(m_InfoMessage, MessageType.Info);
            }
            else
            {
                GUIUtility.GetControlID(s_ControlHash, FocusType.Passive, new Rect(0f, 0f, 0f, 0f));
            }
        }

        foreach (var props in s_GraphProperty.Values)
        {
            MaterialProperty prop = props.title;
            if ((prop.flags & (MaterialProperty.PropFlags.HideInInspector | MaterialProperty.PropFlags.PerRendererData)) == MaterialProperty.PropFlags.None)
            {
                if (props.child != null && props.child.Count > 0)
                {
                    //如果发现有面板,使用Foldout来绘制
                    prop.floatValue = Convert.ToSingle(EditorGUILayout.Foldout(Convert.ToBoolean(prop.floatValue), prop.displayName));
                    if (prop.floatValue == 1f)
                    {
                        foreach (var child in props.child)
                        {
                            DrawGUI(materialEditor, child.title, true);
                        }
                    }
                }
                else
                {
                    DrawGUI(materialEditor, prop, false);
                }
            }
        }

        EditorGUILayout.Space();
        EditorGUILayout.Space();
        if (SupportedRenderingFeatures.active.editableMaterialRenderQueue)
        {
            materialEditor.RenderQueueField();
        }
        materialEditor.EnableInstancingField();
        materialEditor.DoubleSidedGIField();
        //unity 2020 新版本功能 ,老版本需要注释掉
        materialEditor.EmissionEnabledProperty();
    }
예제 #24
0
        public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] properties)
        {
            //init:
            //- read metadata in properties comment to generate ui layout
            //- force update if timestamp doesn't match last (= file externally updated)
            bool force = (shaderImporter != null && shaderImporter.assetTimeStamp != lastTimestamp);

            Initialize(materialEditor, force);

            var shader = (materialEditor.target as Material).shader;

            materialEditor.SetDefaultGUIWidths();

            //show all properties by default
            ShowNextProperty = true;
            ShowStack.Clear();

            for (int i = 0; i < properties.Length; i++)
            {
                if (guiCommands.ContainsKey(i))
                {
                    for (int j = 0; j < guiCommands[i].Count; j++)
                    {
                        guiCommands[i][j].OnGUI();
                    }
                }

                //Use custom properties to enable/disable groups based on keywords
                if (ShowNextProperty)
                {
                    if ((properties[i].flags & (MaterialProperty.PropFlags.HideInInspector | MaterialProperty.PropFlags.PerRendererData)) == MaterialProperty.PropFlags.None)
                    {
                        DisplayProperty(properties[i], materialEditor);
                    }
                }
            }

            //make sure to show gui commands that are after properties
            int index = properties.Length;

            if (guiCommands.ContainsKey(index))
            {
                for (int j = 0; j < guiCommands[index].Count; j++)
                {
                    guiCommands[index][j].OnGUI();
                }
            }

            //Special fields
            Styles.MaterialDrawSeparatorDouble();
            materialEditor.RenderQueueField();
            materialEditor.EnableInstancingField();
        }
예제 #25
0
        public override void OnGUI(MaterialEditor editor, MaterialProperty[] props)
        {
            FetchProperties(props);

            if (IsFirstTimeApply)
            {
                ApplyMaterialChange((Material)editor.target);
                IsFirstTimeApply = false;
            }

            editor.SetDefaultGUIWidths();

            BasicProperties(editor, props);

            EditorGUILayout.Space();
            EditorGUILayout.Space();

            var hasModified = false;

            EditorGUI.BeginChangeCheck();
            {
                AdvancedProperties(editor, props);

                EditorGUILayout.Space();
                EditorGUILayout.Space();
            }

            hasModified = EditorGUI.EndChangeCheck();

            editor.RenderQueueField();

            EditorGUI.BeginChangeCheck();
            {
                if (EnablePerInstanceDataProperty != null)
                {
                    editor.EnableInstancingField();
                    Property(editor, EnablePerInstanceDataProperty);
                }
            }

            hasModified = EditorGUI.EndChangeCheck() || hasModified;

            editor.DoubleSidedGIField();

            if (hasModified)
            {
                foreach (var target in SurfaceProperty.targets)
                {
                    ApplyMaterialChange((Material)target);
                }
            }
        }
예제 #26
0
    public override void OnGUI(MaterialEditor editor, MaterialProperty[] properties)
    {
        this.editor     = editor;
        this.target     = this.editor.target as Material;
        this.properties = properties;
        ShowGUI();
        editor.RenderQueueField();

#if UNITY_5_6_OR_NEWER
        editor.EnableInstancingField();
        target.enableInstancing = true;
#endif
    }
        override public void OnGUI(MaterialEditor materialEditor, MaterialProperty[] properties)
        {
            Material targetMat = materialEditor.target as Material;

            //get properties
            FindProperties(properties, targetMat);

            if (emissionColor.colorValue != Color.black)
            {
                showGIField = true;
            }
            else
            {
                showGIField = false;
            }

            EditorGUI.BeginChangeCheck();
            //main settings
            if (HandleBehavior("Main", showMainBehavior, materialEditor))
            {
                EditorGUI.BeginChangeCheck();

                EditorGUI.BeginChangeCheck();
                ColorProperty(emissionColor, false, true, GUIContentCollection.emissionColor);

                if (showGIField)
                {
                    materialEditor.LightmapEmissionProperty(MaterialEditor.kMiniTextureFieldLabelIndentLevel + 1);
                }
                if (EditorGUI.EndChangeCheck())
                {
                    SetGIFlags();
                }

#if UNITY_5_6_OR_NEWER
                materialEditor.EnableInstancingField();
#endif
            }

            //XRay settings
            if (HandleBehavior("XRay", showXRayBehavior, materialEditor))
            {
                ColorProperty(mainColor, false, false, GUIContentCollection.mainColor);
                materialEditor.ShaderProperty(xRayInside, GUIContentCollection.xRayInside);
                ColorProperty(xRayRimColor, false, true, GUIContentCollection.xRayRimColor);
                materialEditor.ShaderProperty(xRayRimSize, GUIContentCollection.xRayRimSize);
            }

            EditorGUI.EndChangeCheck();
        }
예제 #28
0
        public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] props)
        {
            if (windController == null)
            {
                LocateWindController();
            }
            this.FindProperties(props);

            //Receive
            visualizeVectors = WindController._visualizeVectors;

            this.m_MaterialEditor = materialEditor;

            //Style similar to Standard shader
            m_MaterialEditor.SetDefaultGUIWidths();
            m_MaterialEditor.UseDefaultMargins();
            EditorGUIUtility.labelWidth = 0f;

            //GetGlobalTexture is only available since Unity 5.5
#if UNITY_5_5_OR_NEWER
            hasPigmentMap = (Shader.GetGlobalTexture("_PigmentMap")) ? true : false;
#endif

            EditorGUI.BeginChangeCheck();

            //Draw fields
            DoHeader();

            DoMapsArea();
            DoColorArea();
            DoAnimationArea();
            DoHeightmapArea();
            DoPigmentMapArea();

            if (EditorGUI.EndChangeCheck())
            {
                //Send
                WindController.VisualizeVectors(visualizeVectors);
            }

#if UNITY_5_5_OR_NEWER
            m_MaterialEditor.RenderQueueField();
#endif

#if UNITY_5_6_OR_NEWER
            m_MaterialEditor.EnableInstancingField();
#endif

            DoFooter();
        }
예제 #29
0
    public void ShaderPropertiesGUI(Material material)
    {
        m_MaterialEditor.SetDefaultGUIWidths();

        //if (GUILayout.Button("Set"))
        //{
        //    selectGameObj = Selection.activeGameObject;
        //    SceneView.onSceneGUIDelegate += OnSenceGUI;
        //
        //    //LightDirWindow lightWin = LightDirWindow.Init(material , lightDir.vectorValue);
        //}
        isEditor = GUILayout.Toggle(isEditor, "Set", "Button");
        if (isEditor)
        {
            if (starEditor)
            {
                selectGameObj = Selection.activeGameObject;
                Vector3 localDir = new Vector3(lightDir.vectorValue.x, lightDir.vectorValue.y, lightDir.vectorValue.z);
                Vector3 worldDir = selectGameObj.transform.rotation * localDir;
                rot = Quaternion.FromToRotation(Vector3.forward, worldDir);
                //rot = Quaternion.identity;// Quaternion.FromToRotation(Vector3.forward, selectGameObj.transform.rotation * new Vector3(lightDir.vectorValue.x, lightDir.vectorValue.y, lightDir.vectorValue.z));
                SceneView.onSceneGUIDelegate += OnSenceGUI;
                starEditor = false;
                Debug.Log("starEditor");
            }
        }
        else
        {
            if (!starEditor)
            {
                SceneView.onSceneGUIDelegate -= OnSenceGUI;
                selectGameObj = null;
                starEditor    = true;
                Debug.Log("endEditor");
            }
        }



        EditorGUI.BeginChangeCheck();
        {
        }
        if (EditorGUI.EndChangeCheck())
        {
        }

        m_MaterialEditor.RenderQueueField();
        m_MaterialEditor.EnableInstancingField();
    }
    void DoAdvanced()
    {
        GUILayout.Label("Advanced Options", EditorStyles.boldLabel);

        editor.EnableInstancingField();
        MaterialProperty map0 = FindProperty("_NoiseMap0");
        MaterialProperty map1 = FindProperty("_NoiseMap1");
        MaterialProperty map2 = FindProperty("_NoiseMap2");
        MaterialProperty map3 = FindProperty("_NoiseMap3");

        editor.TexturePropertySingleLine(MakeLabel(map0, "Noise Map 0"), FindProperty("_NoiseMap0"));
        editor.TexturePropertySingleLine(MakeLabel(map1, "Noise Map 1"), FindProperty("_NoiseMap1"));
        editor.TexturePropertySingleLine(MakeLabel(map2, "Noise Map 2"), FindProperty("_NoiseMap2"));
        editor.TexturePropertySingleLine(MakeLabel(map3, "Noise Map 3"), FindProperty("_NoiseMap3"));
    }