当前位置:   article > 正文

assetbundle服务器iis网站,Unity Webgl打ab包放到IIS上

iis unity assetbundles

用编译器和地址都可以实例化出预制体和下载,用浏览器打开程序就无法实例化,打包和下载代码如下

[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);

}

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("cube");

Debug.Log(go.name);

Instantiate(go).transform.position = Vector3.one;

text.text = go.name + "加载成功";

}

}

b9249846b27d7da294a6121163b2869f.png

941f927207522b35db124dd71fdb2903.png

26c19656dbf70bdeeca93a0915d81930.png

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家小花儿/article/detail/92017
推荐阅读
相关标签
  

闽ICP备14008679号