コード例 #1
0
        static void RemoveTessellationMaterials()
        {
            var materials = Resources.FindObjectsOfTypeAll <Material>();

            var litShader        = Shader.Find("HDRenderPipeline/Lit");
            var layeredLitShader = Shader.Find("HDRenderPipeline/LayeredLit");

            foreach (var mat in materials)
            {
                if (mat.shader.name == "HDRenderPipeline/LitTessellation")
                {
                    mat.shader = litShader;
                    // We remove all keyword already present
                    CoreEditorUtils.RemoveMaterialKeywords(mat);
                    LitGUI.SetupMaterialKeywordsAndPass(mat);
                    EditorUtility.SetDirty(mat);
                }
                else if (mat.shader.name == "HDRenderPipeline/LayeredLitTessellation")
                {
                    mat.shader = layeredLitShader;
                    // We remove all keyword already present
                    CoreEditorUtils.RemoveMaterialKeywords(mat);
                    LayeredLitGUI.SetupMaterialKeywordsAndPass(mat);
                    EditorUtility.SetDirty(mat);
                }
            }
        }
コード例 #2
0
 static void SynchronizeAllLayeredMaterial()
 {
     Object[] materials = Resources.FindObjectsOfTypeAll <Material>();
     foreach (Object obj in materials)
     {
         Material mat = obj as Material;
         if (mat.shader.name == "HDRenderLoop/LayeredLit")
         {
             LayeredLitGUI.SynchronizeAllLayers(mat);
         }
     }
 }
コード例 #3
0
        static void SynchronizeAllLayeredMaterial()
        {
            var materials = Resources.FindObjectsOfTypeAll <Material>();

            foreach (var mat in materials)
            {
                if (mat.shader.name == "HDRenderPipeline/LayeredLit" || mat.shader.name == "HDRenderPipeline/LayeredLitTessellation")
                {
                    LayeredLitGUI.SynchronizeAllLayers(mat);
                    EditorUtility.SetDirty(mat);
                }
            }
        }
コード例 #4
0
        static void SynchronizeAllLayeredMaterial()
        {
            var materials = Resources.FindObjectsOfTypeAll <Material>();

            bool VCSEnabled = (UnityEditor.VersionControl.Provider.enabled && UnityEditor.VersionControl.Provider.isActive);

            foreach (var mat in materials)
            {
                if (mat.shader.name == "HDRenderPipeline/LayeredLit" || mat.shader.name == "HDRenderPipeline/LayeredLitTessellation")
                {
                    CoreEditorUtils.CheckOutFile(VCSEnabled, mat);
                    LayeredLitGUI.SynchronizeAllLayers(mat);
                    EditorUtility.SetDirty(mat);
                }
            }
        }
コード例 #5
0
        static void ResetAllMaterialKeywords()
        {
            try
            {
                Object[] materials = Resources.FindObjectsOfTypeAll <Material>();
                for (int i = 0, length = materials.Length; i < length; i++)
                {
                    Material mat = materials[i] as Material;

                    EditorUtility.DisplayProgressBar(
                        "Setup materials Keywords...",
                        string.Format("{0} / {1} materials cleaned.", i, length),
                        i / (float)(length - 1));

                    if (mat.shader.name == "HDRenderPipeline/LayeredLit" || mat.shader.name == "HDRenderPipeline/LayeredLitTessellation")
                    {
                        // We remove all keyword already present
                        RemoveMaterialKeywords(mat);
                        LayeredLitGUI.SetupMaterialKeywordsAndPass(mat);
                        EditorUtility.SetDirty(mat);
                    }
                    else if (mat.shader.name == "HDRenderPipeline/Lit" || mat.shader.name == "HDRenderPipeline/LitTessellation")
                    {
                        // We remove all keyword already present
                        RemoveMaterialKeywords(mat);
                        LitGUI.SetupMaterialKeywordsAndPass(mat);
                        EditorUtility.SetDirty(mat);
                    }
                    else if (mat.shader.name == "HDRenderPipeline/Unlit")
                    {
                        // We remove all keyword already present
                        RemoveMaterialKeywords(mat);
                        UnlitGUI.SetupMaterialKeywordsAndPass(mat);
                        EditorUtility.SetDirty(mat);
                    }
                }
            }
            finally
            {
                EditorUtility.ClearProgressBar();
            }
        }
コード例 #6
0
        void DrawMaterialCopyGUI()
        {
            bool layersChanged = false;
            var  width         = EditorGUIUtility.labelWidth;

            EditorGUIUtility.labelWidth = 90;

            // TODO: does not work with multi-selection
            Material material = materials[0];

            Color originalContentColor = GUI.contentColor;

            float indentOffset    = EditorGUI.indentLevel * 15f;
            float colorWidth      = 14;
            float UVWidth         = 30;
            float copyButtonWidth = EditorGUIUtility.singleLineHeight;
            float endOffset       = 5f;

            Rect headerLineRect         = GUILayoutUtility.GetRect(1, EditorGUIUtility.singleLineHeight);
            Rect headerLabelRect        = new Rect(headerLineRect.x, headerLineRect.y, EditorGUIUtility.labelWidth - indentOffset, headerLineRect.height);
            Rect headerUVRect           = new Rect(headerLineRect.x + headerLineRect.width - 48 - endOffset, headerLineRect.y, UVWidth + 5, headerLineRect.height);
            Rect headerMaterialDropRect = new Rect(headerLineRect.x + headerLabelRect.width, headerLineRect.y, headerLineRect.width - headerLabelRect.width - headerUVRect.width, headerLineRect.height);

            EditorGUI.LabelField(headerLabelRect, Styles.layerNameHeader, EditorStyles.centeredGreyMiniLabel);
            EditorGUI.LabelField(headerMaterialDropRect, Styles.materialToCopyHeader, EditorStyles.centeredGreyMiniLabel);
            EditorGUI.LabelField(headerUVRect, Styles.uvHeader, EditorStyles.centeredGreyMiniLabel);

            for (int layerIndex = 0; layerIndex < numLayer; ++layerIndex)
            {
                using (new EditorGUILayout.HorizontalScope())
                {
                    EditorGUI.BeginChangeCheck();

                    Rect lineRect     = GUILayoutUtility.GetRect(1, EditorGUIUtility.singleLineHeight);
                    Rect colorRect    = new Rect(lineRect.x, lineRect.y, colorWidth, lineRect.height);
                    Rect materialRect = new Rect(lineRect.x + colorRect.width, lineRect.y, lineRect.width - UVWidth - colorWidth - copyButtonWidth + endOffset, lineRect.height);
                    Rect uvRect       = new Rect(lineRect.x + lineRect.width - copyButtonWidth - UVWidth - endOffset, lineRect.y, UVWidth, lineRect.height);
                    Rect copyRect     = new Rect(lineRect.x + lineRect.width - copyButtonWidth - endOffset, lineRect.y, copyButtonWidth, lineRect.height);

                    m_MaterialLayers[layerIndex] = EditorGUI.ObjectField(materialRect, Styles.layerLabels[layerIndex], m_MaterialLayers[layerIndex], typeof(Material), true) as Material;
                    if (EditorGUI.EndChangeCheck())
                    {
                        Undo.RecordObject(m_MaterialImporter, "Change layer material");
                        LayeredLitGUI.SynchronizeLayerProperties(material, m_MaterialLayers, layerIndex, true);
                        layersChanged = true;
                    }


                    colorRect.width  = 30f;
                    GUI.contentColor = kLayerColors[layerIndex];
                    EditorGUI.LabelField(colorRect, "■");
                    GUI.contentColor = originalContentColor;

                    m_WithUV[layerIndex] = EditorGUI.Toggle(uvRect, m_WithUV[layerIndex]);

                    if (GUI.Button(copyRect, GUIContent.none))
                    {
                        LayeredLitGUI.SynchronizeLayerProperties(material, m_MaterialLayers, layerIndex, !m_WithUV[layerIndex]);
                        layersChanged = true;
                    }

                    //fake the icon with two Console icon
                    //Rect copyRect = GUILayoutUtility.GetLastRect();
                    copyRect.x    -= 16;
                    copyRect.width = 40;
                    EditorGUI.LabelField(copyRect, Styles.copyButtonIcon);
                    copyRect.x -= 3;
                    copyRect.y += 3;
                    EditorGUI.LabelField(copyRect, Styles.copyButtonIcon);
                }
            }

            EditorGUIUtility.labelWidth = width;

            if (layersChanged)
            {
                foreach (var mat in materials)
                {
                    LayeredLitGUI.SetupMaterialKeywordsAndPass(mat);
                }

                // SaveAssetsProcessor the referenced material in the users data
                if (m_MaterialImporter != null)
                {
                    LayeredLitGUI.SaveMaterialLayers(material, m_MaterialLayers);
                }

                // We should always do this call at the end
                materialEditor.serializedObject.ApplyModifiedProperties();
            }
        }