AssetBundle.CreateFromFile使用时注意事项

来源:互联网 发布:c语言中求绝对值 编辑:程序博客网 时间:2024/06/09 17:05

在使用AssetBundle.CreateFromFile加载AssetBundle时有两点需要注意


1:在创建资源包时需要选择不压缩(unity5.x资源打包方式)

AssetBundleManifest amf  = BuildPipeline.BuildAssetBundles(assetPath , abbs ,BuildAssetBundleOptions.UncompressedAssetBundle , bTarget);

2:在读取时需要注意文件路径

如果打的 AssetBundle 包b.unity3d放在工程目录下的asb文件夹下,则此时路径为:Application.dataPath  + "/ASB/b.unity3d"

AssetBundle asb = AssetBundle.CreateFromFile(Application.dataPath  + "/ASB/b.unity3d");


附:

若使用www加载本地AssetBundle则需要在路径前加“file://”即

"file://" + Application.dataPath  + "/ASB/b.unity3d"


StreamingAssets目录下的资源不同平台的路径:

#if UNITY_EDITOR#if UNITY_EDITOR_OSXpath = "file://" + Application.streamingAssetsPath+"/ASB_Ios/sound.unity3d";#elsepath = "file://" + Application.streamingAssetsPath+"/ASB_Android/sound.unity3d";#endif#elif UNITY_ANDROIDpath = Application.streamingAssetsPath+"/ASB_Android/sound.unity3d";#elif UNITY_IOSpath = "file://"+Application.streamingAssetsPath+"/ASB_Ios/sound.unity3d";//path = "file://"+Application.dataPath + "/Raw/ASB_Ios/sound.unity3d";// + filename;#elsepath = Application.streamingAssetsPath+"/ASB_Android/sound.unity3d";#endif



资源打包:http://blog.csdn.net/fucun1984686003/article/details/51683035

0 0
原创粉丝点击