Unity Webgl打ab包放到IIS上
时间: 2019-06-03来源:博客园
前景提要
Unity Webgl打ab包放到IIS上
0 悬赏园豆: 50 [待解决问题] 用编译器和地址都可以实例化出预制体和下载,用浏览器打开程序就无法实例化,打包和下载代码如下
[MenuItem("AssetBundle/Package (Default)")]
static void PutBundleAssetesAll()
{
//将这些资源包放在一个名为ABs的目录下
// string assetBundleDirectory = "E:/UnityProject/ceshi/aboundceTest/assetbundle";
string assetBundleDirectory = "Assets/StreamingAssets/assetbundle";
//如果目录不存在,就创建一个目录
if (!Directory.Exists(assetBundleDirectory))
{
Directory.CreateDirectory(assetBundleDirectory);
}
BuildPipeline.BuildAssetBundles(assetBundleDirectory, BuildAssetBundleOptions.None, BuildTarget.StandaloneWindows64);
}
//string url = " http://192.168.11.114:8089/StreamingAssets/assetbundle/cube.unity3d ";
//string url = " http://localhost:8089/StreamingAssets/assetbundle/cube.unity3d ";
IEnumerator LoadABB(string url)
{ UnityWebRequest request = UnityWebRequestAssetBundle.GetAssetBundle(url); yield return request.SendWebRequest(); if (request.isNetworkError) { text.text = request.error; } else { AssetBundle ab = DownloadHandlerAssetBundle.GetContent(request); GameObject go = ab.LoadAsset<GameObject>("cube"); Debug.Log(go.name); Instantiate(go).transform.position = Vector3.one; text.text = go.name + "加载成功"; } }


想不开的教书人 | 初学一级 | 园豆: 152
提问于:2019-06-03 10:57 显示帮助
使用"Ctrl+Enter"可进行快捷提交,评论支持部分 Markdown 语法:[link](http://example.com) _italic_ **bold** `code`。
< > 分享
分享您的问题

清除回答草稿
您需要 登录 以后才能回答,未注册用户请先 注册 。

科技资讯:

科技学院:

科技百科:

科技书籍:

网站大全:

软件大全:

热门排行