Skip to content

Instantly share code, notes, and snippets.

@dimmduh
Created December 24, 2019 15:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dimmduh/32c5b478c01c1429af91780b3a8aa383 to your computer and use it in GitHub Desktop.
Save dimmduh/32c5b478c01c1429af91780b3a8aa383 to your computer and use it in GitHub Desktop.
Unity. Change material standard shader blend mode.
//see https://github.com/Unity-Technologies/UnityCsReference/blob/9034442437e6b5efe28c51d02e978a96a3ce5439/Editor/Mono/Inspector/StandardShaderGUI.cs
//blend mode 3 - transparent
public static void SetupMaterialWithBlendMode(Material material, int blendMode)
{
var assembly = Assembly.GetAssembly(typeof(Editor));
var type = assembly.GetType("UnityEditor.StandardShaderGUI");
var method = type.GetMethod("SetupMaterialWithBlendMode");
method.Invoke(null, new object[] {material, blendMode});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment