本文整理汇总了C#中UnityEditor.MaterialEditor.SetShader方法的典型用法代码示例。如果您正苦于以下问题:C# MaterialEditor.SetShader方法的具体用法?C# MaterialEditor.SetShader怎么用?C# MaterialEditor.SetShader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEditor.MaterialEditor
的用法示例。
在下文中一共展示了MaterialEditor.SetShader方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnGUI
//TODO: see if there is a better callback function
public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] properties)
{
string content = File.ReadAllText(TEMPLATE_PATH);
content = content.Replace(ORIGINAL_SHADER_NAME, string.Format(SHADER_NAME_SYNTAX, materialEditor.target.name.Split(' ')[0]));
content = content.Replace(PRE_EDITOR, EDITOR);
File.WriteAllText(string.Format(OUTPUT_PATH, materialEditor.target.name.Split(' ')[0] + ".shader"), content);
AssetDatabase.ImportAsset (string.Format(RELATIVE_OUTPUT_PATH, materialEditor.target.name.Split(' ')[0] + ".shader"));
Shader shader = Shader.Find(string.Format(SHADER_NAME_SYNTAX, materialEditor.target.name));
materialEditor.SetShader(shader);
}
示例2: ShaderLightingSelection
//The Shader Lighting selection in the Extras Panel
private void ShaderLightingSelection(Material mat, MaterialEditor matEditor)
{
//This is the Header
GUILayout.BeginHorizontal();
GUILayout.Box("Lighting Style Selector", EditorStyles.centeredGreyMiniLabel, GUILayout.ExpandWidth(true));
ButtonOpenUrl(_btnHelp, "http://wiki.next-gen-sprites.com/doku.php?id=shaders:lighting");
GUILayout.EndHorizontal();
GUILayout.Space(5f);
var indexLitStyle = 0;
//Labels for Buttons
var labelLitStyle = new[] { "Multi Lit", "Single Lit", "Unlit" };
//Used to seek and assign Shaders by Name
var litStyle = new[] { "Multi", "Single", "Unlit" };
var splited = mat.shader.name.Split('/');
var lastWord = splited[splited.Length - 1];
//The Toolbar uses an index, we get it by comparing the string
for (var i = 0; i < litStyle.Length; i++)
{
if (lastWord != litStyle[i])
continue;
indexLitStyle = i;
break;
}
indexLitStyle = GUILayout.Toolbar(indexLitStyle, labelLitStyle, GUILayout.ExpandWidth(true), GUILayout.Height(32f));
if (GUI.changed)
{
_rebuildPanel = true;
GUILayout.Space(8f);
DrawWideBox();
//Build String and assign it as Shader
var mainResult = "NextGenSprites/Standard" + "/" + litStyle[indexLitStyle];
//Check if it realy is a different Shader then the current
if(string.CompareOrdinal(_matTarget.shader.name, mainResult) != 0)
matEditor.SetShader(Shader.Find(mainResult));
}
}