当前位置: 首页>>代码示例>>C#>>正文


C# MaterialEditor.SetShader方法代码示例

本文整理汇总了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);
 }
开发者ID:moe-ped,项目名称:SolidTextures,代码行数:11,代码来源:FractalMaterialPreEditor.cs

示例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));
        }
    }
开发者ID:cuongngo90,项目名称:Unity-SpriteShader,代码行数:46,代码来源:NGSMaterialInspector.cs


注:本文中的UnityEditor.MaterialEditor.SetShader方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。