Empty shader re-designation tool

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.