UnityEditor.BabylonShaderInterface.AssignNewShaderToMaterial C# (CSharp) Method

AssignNewShaderToMaterial() public method

public AssignNewShaderToMaterial ( Material material, Shader oldShader, Shader newShader ) : void
material UnityEngine.Material
oldShader UnityEngine.Shader
newShader UnityEngine.Shader
return void
		public override void AssignNewShaderToMaterial (Material material, Shader oldShader, Shader newShader)
		{
			// _Emission property is lost after assigning Standard shader to the material
			// thus transfer it before assigning the new shader
			if (material.HasProperty("_Emission"))
			{
				material.SetColor("_EmissionColor", material.GetColor("_Emission"));
			}

			base.AssignNewShaderToMaterial(material, oldShader, newShader);

			if (oldShader == null || !oldShader.name.Contains("Legacy Shaders/"))
			{
				SetupMaterialWithBlendMode(material, (BlendMode)material.GetFloat("_Mode"));
				return;
			}

			BlendMode blendMode = BlendMode.Opaque;
			if (oldShader.name.Contains("/Transparent/Cutout/"))
			{
				blendMode = BlendMode.Cutout;
			}
			else if (oldShader.name.Contains("/Transparent/"))
			{
				// NOTE: legacy shaders did not provide physically based transparency
				// therefore Fade mode
				blendMode = BlendMode.Fade;
			}
			material.SetFloat("_Mode", (float)blendMode);

			DetermineWorkflow( MaterialEditor.GetMaterialProperties (new Material[] { material }) );
			MaterialChanged(material, m_WorkflowMode);
		}