Beispiel #1
0
            public void AdjustNonTextureProperties(Material resultMat, List <ShaderTextureProperty> texPropertyNames, List <MB_TexSet> distinctMaterialTextures, MB2_EditorMethodsInterface editorMethods)
            {
                if (resultMat == null || texPropertyNames == null)
                {
                    return;
                }

                //try to use a texture blender if we can find one to set the non-texture property values
                if (_textureProperties.LOG_LEVEL >= MB2_LogLevel.debug)
                {
                    Debug.Log("Adjusting non texture properties using TextureBlender for shader: " + resultMat.shader.name);
                }
                resultMaterialTextureBlender.SetNonTexturePropertyValuesOnResultMaterial(resultMat);

                if (editorMethods != null)
                {
                    editorMethods.CommitChangesToAssets();
                }
            }
Beispiel #2
0
            public void AdjustNonTextureProperties(Material resultMat, List <ShaderTextureProperty> texPropertyNames, List <MB_TexSet> distinctMaterialTextures, MB2_EditorMethodsInterface editorMethods)
            {
                Debug.Assert(_textureProperties._considerNonTextureProperties == false);
                if (resultMat == null || texPropertyNames == null)
                {
                    return;
                }
                for (int nonTexPropIdx = 0; nonTexPropIdx < _textureProperties._nonTextureProperties.Length; nonTexPropIdx++)
                {
                    MaterialProperty nonTexProperty = _textureProperties._nonTextureProperties[nonTexPropIdx];
                    if (resultMat.HasProperty(nonTexProperty.PropertyName))
                    {
                        nonTexProperty.GetAverageCalculator().SetAverageValueOrDefaultOnMaterial(resultMat, nonTexProperty);
                    }
                }

                if (editorMethods != null)
                {
                    editorMethods.CommitChangesToAssets();
                }
            }
 //If we are switching from a Material that uses color properties to
 //using atlases don't want some properties such as _Color to be copied
 //from the original material because the atlas texture will be multiplied
 //by that color
 void AdjustNonTextureProperties(Material mat, List<ShaderTextureProperty> texPropertyNames, List<MB_TexSet> distinctMaterialTextures, MB2_EditorMethodsInterface editorMethods)
 {
     if (mat == null || texPropertyNames == null) return;
     for (int i = 0; i < texPropertyNames.Count; i++){
         string nm = texPropertyNames[i].name;
         if (nm.Equals("_MainTex")){
             if (mat.HasProperty("_Color")){
                 try{
                     mat.SetColor("_Color",distinctMaterialTextures[0].ts[i].tintColor);
                 } catch(Exception){}
             }
         }
         if (nm.Equals("_BumpMap")){
             if (mat.HasProperty("_BumpScale")){
                 try{
                     mat.SetFloat("_BumpScale",1f);
                 } catch(Exception){}
             }
         }
         if (nm.Equals("_ParallaxMap")){
             if (mat.HasProperty("_Parallax")){
                 try{
                     mat.SetFloat("_Parallax",.02f);
                 } catch(Exception){}
             }
         }
         if (nm.Equals("_OcclusionMap")){
             if (mat.HasProperty("_OcclusionStrength")){
                 try{
                     mat.SetFloat("_OcclusionStrength",1f);
                 } catch(Exception){}
             }
         }
         if (nm.Equals("_EmissionMap")){
             if (mat.HasProperty("_EmissionColorUI")){
                 try{
                     mat.SetColor("_EmissionColorUI",new Color(1f,1f,1f,1f));
                 } catch(Exception){}
             }
             if (mat.HasProperty("_EmissionScaleUI")){
                 try{
                     mat.SetFloat("_EmissionScaleUI",1f);
                 } catch(Exception){}
             }
         }
     }
     if (editorMethods != null){
         editorMethods.CommitChangesToAssets();
     }
 }
 //If we are switching from a Material that uses color properties to
 //using atlases don't want some properties such as _Color to be copied
 //from the original material because the atlas texture will be multiplied
 //by that color
 internal void AdjustNonTextureProperties(Material mat, List <ShaderTextureProperty> texPropertyNames, List <MB_TexSet> distinctMaterialTextures, bool considerTintColor, MB2_EditorMethodsInterface editorMethods)
 {
     if (mat == null || texPropertyNames == null)
     {
         return;
     }
     if (_considerNonTextureProperties)
     {
         //try to use a texture blender if we can find one to set the non-texture property values
         if (LOG_LEVEL >= MB2_LogLevel.debug)
         {
             Debug.Log("Adjusting non texture properties using TextureBlender for shader: " + mat.shader.name);
         }
         resultMaterialTextureBlender.SetNonTexturePropertyValuesOnResultMaterial(mat);
         return;
     }
     if (LOG_LEVEL >= MB2_LogLevel.debug)
     {
         Debug.Log("Adjusting non texture properties on result material");
     }
     for (int i = 0; i < texPropertyNames.Count; i++)
     {
         string nm = texPropertyNames[i].name;
         if (nm.Equals("_MainTex"))
         {
             if (mat.HasProperty("_Color"))
             {
                 try
                 {
                     if (considerTintColor)
                     {
                         //tint color was baked into atlas so set to white;
                         mat.SetColor("_Color", Color.white);
                     }
                     else
                     {
                         //mat.SetColor("_Color", distinctMaterialTextures[0].ts[i].tintColor);
                     }
                 }
                 catch (Exception) { }
             }
         }
         if (nm.Equals("_BumpMap"))
         {
             if (mat.HasProperty("_BumpScale"))
             {
                 try
                 {
                     mat.SetFloat("_BumpScale", 1f);
                 }
                 catch (Exception) { }
             }
         }
         if (nm.Equals("_ParallaxMap"))
         {
             if (mat.HasProperty("_Parallax"))
             {
                 try
                 {
                     mat.SetFloat("_Parallax", .02f);
                 }
                 catch (Exception) { }
             }
         }
         if (nm.Equals("_OcclusionMap"))
         {
             if (mat.HasProperty("_OcclusionStrength"))
             {
                 try
                 {
                     mat.SetFloat("_OcclusionStrength", 1f);
                 }
                 catch (Exception) { }
             }
         }
         if (nm.Equals("_EmissionMap"))
         {
             if (mat.HasProperty("_EmissionColor"))
             {
                 try
                 {
                     mat.SetColor("_EmissionColor", new Color(0f, 0f, 0f, 0f));
                 }
                 catch (Exception) { }
             }
             if (mat.HasProperty("_EmissionScaleUI"))
             {
                 try
                 {
                     mat.SetFloat("_EmissionScaleUI", 1f);
                 }
                 catch (Exception) { }
             }
         }
     }
     if (editorMethods != null)
     {
         editorMethods.CommitChangesToAssets();
     }
 }