如果加载的AB包存放的位置是 当前项目文件夹的位置, 如下。
"AssetBundles/item"
AB包精确的文件夹位置,本地其他项目的AB包也可以同样进行读取
"E:/Unity/UnityProjects/UnityProjects_TestAndroid/Android/AssetBundles/item"
...
private void test()
{
// AssetBundle ab = AssetBundle.LoadFromFile("AssetBundles/item");//加载本地AB包内容
AssetBundle ab = AssetBundle.LoadFromFile("E:/Unity/UnityProjects/UnityProjects_TestAndroid/Android/AssetBundles/item");//加载本地AB包内容
if (image != null)
{
Texture2D tex = ab.LoadAsset<Texture2D>("test.1.png");
Sprite mySprite = Sprite.Create(tex, new Rect(0.0f, 0.0f, tex.width, tex.height), new Vector2(0.5f, 0.5f), 100.0f);
//设置Image的Sprite
image.sprite = mySprite;
}//
}//
...
E:\Unity\UnityProjects\UnityProjects_TestAndroid\Android\AssetBundles
红色方框,就是 根据不同 AssetBundle分组 打包后,生成的文件。