【发布时间】:2016-10-28 15:45:08
【问题描述】:
我正在开发从我的 htdocs 加载资产包的 Unity 应用程序,该应用程序将在 iPhone 上运行。
当内容获取工作(afaik)时,加载停止大约一半,Xcode 吐出以下错误:
Unloading 3 Unused Serialized files (Serialized files now loaded: 0)
UnloadTime: 13.037000 ms
Unloading 50 unused Assets to reduce memory usage. Loaded Objects now: 733.
Total: 10.006415 ms (FindLiveObjects: 0.065750 ms CreateObjectMapping: 0.033250 ms MarkObjects: 0.951208 ms DeleteObjects: 8.955166 ms)
2016-10-26 18:34:58.882 CookieJarApp[6245:1953469] You are using download over http. Currently unity adds NSAllowsArbitraryLoads to Info.plist to simplify transition, but it will be removed soon. Please consider updating to https.
Asset bundle [ios_cookie_prefabs] loaded.
<CoLoadAssetBundle>d__20:MoveNext()
(Filename: /Users/builduser/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 37)
The file can not be loaded because it was created for another build target that is not compatible with this platform.
Please make sure to build AssetBundles using the build target platform that it is used by.
File's Build target is: 13
<CoLoadAssetBundle>d__20:MoveNext()
[ line 907]
(Filename: Line: 907)
The AssetBundle 'http://192.168.1.241:80/CookieJarApp_test/ios_cookie_prefabs' can't be loaded because it was not built with the right version or build target.
<CoLoadAssetBundle>d__20:MoveNext()
[ line 406]
(Filename: Line: 406)
NullReferenceException: A null value was found where an object instance was required.
at AssetBundleController.GetGameObject (System.String bundleID, System.String objectName) [0x00000] in <filename unknown>:0
at AssetBundleController.UnloadAll () [0x00000] in <filename unknown>:0
at Loader+<LoadPrefabs>c__AnonStorey22.<>m__15 (UnityEngine.AssetBundle bundle) [0x00000] in <filename unknown>:0
at AssetBundleController+<CoLoadAssetBundle>d__20.MoveNext () [0x00000] in <filename unknown>:0
(Filename: currently not available on il2cpp Line: -1)
但是,我使用 Build Settings 中选择的 iOS 平台构建了预制件(本身就是另一个游戏)。
有人告诉我,资产包不同,还有什么我可以尝试的吗?
这是CoLoadAssetBundle 函数:
// Start a download of the given URL
WWW www = new WWW(url);
while (!www.isDone)
{
Debug.Log("[" + bundleId + "] Progress:" + www.progress * 100f + "%");
yield return null;
}
if (string.IsNullOrEmpty(www.error))
{
Debug.Log("Asset bundle [" + bundleId + "] loaded.");
m_assetBundleList.Add(new AssetBundleStruct(bundleId, www.assetBundle));
}
else
{
Debug.Log("Asset bundle [" + bundleId + "] not loaded!\n[" + www.error + "]");
}
www.Dispose();
【问题讨论】:
-
您用来加载资源包的代码在哪里?
-
@Programmer,啊,现在不在我身边,我明天回来时必须更新这个。 FWIW,我们已经使用相同的代码创建了至少一个可以完美运行的 Asset Bundle,我认为那里不会有问题。
-
@Programmer,我已经添加了一些代码,希望对您有所帮助。
-
我说的是用于从设备加载它的代码,而不是用于构建它的代码。同时,请看我的回答。
-
@Programmer,我的错,对不起。我已经编辑了问题。