Using Unityengine;
Using Unityeditor;
Using System.Collections;
public class Checkcharactershader:editorwindow
{
<summary>
Detects if the character material is missing shader lost and re-identified
Please copy the script to the editor file right click to execute
</summary>
Static Checkcharactershader Listwindow;
private string Checkpath = "Assets/art/characters";
[MenuItem ("Assets/checkcharactershader")]
Use this for initialization
static void Start ()
{
Listwindow = (checkcharactershader) Editorwindow.getwindow (typeof (Checkcharactershader), true, "role null shader specified");
Listwindow.minsize = new Vector2 (600,200);
Listwindow.show ();
}
void Ongui ()
{
if (Guilayout.button ("role null shader specified", Guilayout.height (40)))
{
Assignnullshader ();
}
}
void Assignnullshader ()
{
string[] PathList = assetdatabase.findassets ("T:material", new string[] {checkpath});
for (int i = 0; i < pathlist.length; ++i)
{
String matpath = Assetdatabase.guidtoassetpath (Pathlist[i]);
if (Matpath.contains ("Models") &&!matpath.contains ("Effects")
{
Material Material = Assetdatabase.loadassetatpath (Matpath, typeof (Material)) as Material;
if (Material.shader = = Shader.find ("Hidden/internalerrorshader"))
{
Material.shader = Shader.find ("Dreamfaction/characters/characters");
}
}
}
Assetdatabase.refresh ();
This. Shownotification (New Guicontent ("Project has been updated!"));
}
}
Empty shader re-designation tool