美文网首页
unity获取丢失shader的material

unity获取丢失shader的material

作者: 红定义 | 来源:发表于2017-03-07 08:38 被阅读0次

    UnityEngine.Object _obj = AssetDatabase.LoadAssetAtPath(_materialPath + @"\" + _materialFiles[j].Name, typeof(UnityEngine.Object)) as UnityEngine.Object;

    if (_obj == null)

    {

    DebugX.Log(_materialFiles[j].Name + " is null.");

    continue;

    }

    Material _mat = (Material)_obj;

    _mat.shader = Shader.Find("Toon/Diffuse");

    Texture _textureMain = AssetDatabase.LoadAssetAtPath(_assetsPath + @"\" + _dirName + ".tga", typeof(Texture)) as Texture;

    if (null != _textureMain)

    {

    _mat.mainTexture = _textureMain;

    }

    else

    {

    DebugX.LogError(_dirName + " Texture is null.");

    }

    相关文章

      网友评论

          本文标题:unity获取丢失shader的material

          本文链接:https://www.haomeiwen.com/subject/kkvpgttx.html