SetShader() public method

public SetShader ( Shader shader ) : void
shader UnityEngine.Shader
return void
 //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);
 }
    //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));
        }
    }