[Unity][AssetBundle]从AB包中加载Material材质球

 

 

名字为111的AB包中 已经有打包的材质 名字为 test

 

...
using UnityEditor;
...
    public AssetBundle ab_material;
    public Material m;
...
/// <summary>
    /// 从 111 ab包中 获取 名字为test的材质
    /// </summary>
    private void testGetMaterial()
    {
string str_material = Application.persistentDataPath+"/111";//注意AB包的 打包平台是否正确
            ab_material = AssetBundle.LoadFromFile(str_material);//加载本地AB包内容
        if (ab_material != null)
        {
            m = ab_material.LoadAsset<Material>("test");
        }//
    }//
...

 

 

 

 


版权声明:本文为BuladeMian原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。