- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试为我目前正在开发的游戏测试一些 AssetBundle。我想使用它是因为我不想让游戏占用太多空间。我仍然不知道服务器如何工作以及如何将它们上传到那里。我正在搜索如何执行此操作,并在此处找到了一些巧妙的东西:AssetBundle (DLC) data load to Android phone at runtime [UNITY]但它讲述了一些关于上传到服务器和东西的东西,但我想在本地测试它。有什么推荐吗?
根据 Remy 告诉我的内容,我的代码如下所示:
public class LoadFromFileExample : MonoBehaviour {
// Use this for initialization
void Start () {
string fileName = "planes";
var myLoadedAssetBundle = AssetBundle.LoadFromFile(Path.Combine(Application.streamingAssetsPath, fileName));
if (myLoadedAssetBundle == null)
{
Debug.Log("Failed to load AssetBundle!");
return;
}
var prefab = myLoadedAssetBundle.LoadAsset< GameObject > ("andy");
Instantiate(prefab);
myLoadedAssetBundle.Unload(false);
}
// Update is called once per frame
void Update () {
}
}
但它显示以下错误:无法打开存档文件:C:/Users/Chris/Desktop/myDLC/Assets/StreamingAssets/myassetBundle
最佳答案
这允许您从设备的本地存储加载您的 assetbundle 文件。这意味着您不必先上传/下载它们。
它看起来像下面这样:
string fileName = "fooAssetBundle";//name of the assetbundle you want to load
var myLoadedAssetBundle = AssetBundle.LoadFromFile(Path.Combine(Application.streamingAssetsPath, fileName));//Creates a filepath starting at the streamingAssetsPath and appends filename to it.
var prefab = myLoadedAssetBundle.LoadAsset<GameObject>("MyObject");//Create a GameObject from the assetbundle
Instantiate(prefab);//instantiate the GameObject
myLoadedAssetBundle.Unload(false);//Unload the assetbundle from memory as it isn't used anymore
上面的示例使用了 Application.StreamingAssetsPath
但这可以是您想要的任何路径,例如 Application.PersistentDataPath
或外部存储。
关于android - 我如何在 Unity 的 Android 上本地测试 AssetBundle (DLC)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54675260/
我希望将额外的内容作为额外的数据库添加到我的应用程序中。我是否应该将它们放在 apk 和内容提供程序中,以便它们可以直接从 google play 更新,或者就像直接将新的 db 文件下载到应用程序中
我想为一家公司设计一个企业应用程序,允许他们的员工将模块下载到应用程序上,其中包含有关特定产品的信息,即文本、图像、视频等。 我知道应用内购买不适用于企业应用,而且我不想向任何人收取下载内容的费用。我
我有以下代码: int bitSwitcher = (1 > n; int logShift = arthShift ^ bitSwitcher; int xSign = x >> 31; int w
我正在构建一个 Android 应用程序,为用户提供多个交互式冒险。它们使用大量媒体(声音文件和图像,加上一些 xml),因此占用大量空间。 我正计划采用免费增值模式,在这种模式下,用户可以免费下载一
我正在为 iOS 开发一款游戏,我需要制作一个系统来在玩家通过应用内购买购买“包”后下载它们。 我在 Internet 上搜索了一种方法,例如使用 bundle 或仅使用 Web 服务,但我真的不知道
我正在尝试为我目前正在开发的游戏测试一些 AssetBundle。我想使用它是因为我不想让游戏占用太多空间。我仍然不知道服务器如何工作以及如何将它们上传到那里。我正在搜索如何执行此操作,并在此处找到了
最近我一直在尝试阅读一位 friend 推荐的《csapp》这本书。当我试图完成实验作业时,事情发生了 datalab-handout (需要下载)。 当我尝试在 MacOSX Yosemite 中运
我是一名优秀的程序员,十分优秀!