我们正在构建一个Hololens应用程序,它将使用设备文件夹中的资产包,但是当试图加载包文件时,我们会遇到一个“无法打开归档文件”的错误。
由于我们在资产包方面的经验不多,所以我们首先创建了一个非常简单的包文件(只有几个United原语和材料),我们第一次尝试将它们从Unity加载到应用程序中。这是正常运行的,但当我们将应用程序部署到Hololens中时,它就失败了。
这是我们的装载方法:
#if WINDOWS_UWP
public async void CallForBundles()
#else
public void CallForBundles()
#endif
{
string bundleFile = "--- NO BUNDLE ---";
#if UNITY_EDITOR
bundleFile = @"D:\temp\UnityBuilds\AssetBundles\exportablebundle";
#endif
#if WINDOWS_UWP
Windows.Storage.StorageFolder objectsFolder = Windows.Storage.KnownFolders.Objects3D;
Windows.Storage.StorageFile bundleFilePointer = await objectsFolder.GetFileAsync("exportablebundle");
bundleFile = bundleFilePointer.Path;
#endif
var myLoadedAB = AssetBundle.LoadFromFile(bundleFile);
//instante bundle components from myLoadedAB//
}正如你所看到的是非常简单的事情。根据平台的不同,我们通过不同的方法找到捆绑路径(我们已经将这个系统用于文本文件、pngs和其他),而UNITY_EDITOR端正在工作。WINDOWS_UWP只是在调用AssetBundle.LoadFromFile(BundleFile)时抛出此错误;:
Unable to open archive file: C:/Data/Users/edata/3D Objects/exportablebundle
(Filename: C:\buildslave\unity\build\Runtime/VirtualFileSystem/ArchiveFileSystem/ArchiveStorageReader.cpp Line: 542)
'Holoplan.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\HoloplanVS.Release_x86.jalfonso\System.Diagnostics.StackTrace.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
NullReferenceException: Object reference not set to an instance of an object.
at GameManager.<CallForBundles>d__1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<>c.<ThrowAsync>b__6_0(Object state)
at UnityEngine.UnitySynchronizationContext.WorkRequest.Invoke()
at UnityEngine.UnitySynchronizationContext.Exec()
at UnityEngine.UnitySynchronizationContext.ExecuteTasks()
at UnityEngine.UnitySynchronizationContext.$Invoke1(Int64 instance, Int64* args)
at UnityEngine.Internal.$MethodUtility.InvokeMethod(Int64 instance, Int64* args, IntPtr method)
(Filename: <Unknown> Line: 0)无法打开存档文件: C:/Data/Users/edata/3D对象/exportablebundle
当应用程序试图加载一个包含错误文件名或路径的bunde时,即使在编辑器上运行时,似乎也会发生相同的错误,因此,由于某种原因,“AssetBundle.LoadFromFile”无法找到de文件。我们检查了该行中的bundleFile,它包含了正确的文件路径('C:\Data\Users\edata\3D Objects\exportablebundle‘,其中'exportablebundle’是包文件名),所以我们猜测'AssetBundle.LoadFromFile‘在从Hololens本地文件夹读取时会出现问题,但是我们对如何解决这个问题不太了解。
谁能帮我们一把,好吗?
编辑-
我们正在使用“asset工作流”中的United手册中的示例代码构建我们的资产包。是这样的:
static void BuildAllAssetBundles(){
string assetBundleDirectory = "Assets/AssetBundles";
if (!Directory.Exists(assetBundleDirectory)){
Directory.CreateDirectory(assetBundleDirectory);
}
BuildPipeline.BuildAssetBundles(assetBundleDirectory, BuildAssetBundleOptions.None, BuildTarget.StandaloneWindows);
}“StandaloneWindows”作为构建目标,从可用列表上看似乎是最接近全息透镜的,因此我们选择了它。
发布于 2019-05-29 10:14:18
抱歉,资产捆绑现在在HL设备上不起作用。这是已知的问题,必须解决。
https://stackoverflow.com/questions/56341690
复制相似问题