简体   繁体   English

Unity3D Hololens 访问 Windows.Storage.KnownFolders

[英]Unity3D Hololens access Windows.Storage.KnownFolders

I need to access the PicturesLibrary fodler on the Hololens.我需要访问 Hololens 上的 PicturesLibrary fodler。 Docs state that you can do that by "Windows.Storage.PicturesLibrary"文档说明您可以通过“Windows.Storage.PicturesLibrary”做到这一点

But I can not import the namespace "Windows" in my Unity project because its not included in UWP, also it should be possible.但是我无法在我的 Unity 项目中导入命名空间“Windows”,因为它不包含在 UWP 中,也应该是可能的。 I am using the Unity3D 2019.2 with .net 4.x我正在使用 Unity3D 2019.2 和 .net 4.x

How can I load pictures from the folder the right way with the HoloLens?如何使用 HoloLens 以正确的方式从文件夹中加载图片?

I tried some examples from similar questions but none of them worked, like eg.g:我尝试了类似问题中的一些示例,但没有一个起作用,例如:

#if !UNITY_EDITOR && UNITY_WINRT_10_0
return Windows.Storage.KnownFolders.PicturesLibrary.Path;                 
#else

@crani have you set the UWP App Capability declaratio n for PicturesLibrary access? @crani 您是否为 PicturesLibrary 访问设置了 UWP 应用程序功能声明

note that the docs mention that the capability provides access to "enumerate" the files in the library.请注意,文档提到该功能提供了对“枚举”库中文件的访问。 Path is typically going to be an empty string for any of the KnowFolder types.对于任何 KnowFolder 类型,Path 通常是一个空字符串。

You will need to do something like this:你需要做这样的事情:

StorageFolder picturesFolder = KnownFolders.PicturesLibrary;
IReadOnlyList<StorageFile> pictures = await picturesFolder.GetFilesAsync();

So if you wrap something similar in an #if directive you should be able to access the files, but the path is abstracted from the app as a storage folder.因此,如果您将类似的内容包装在 #if 指令中,您应该能够访问这些文件,但该路径是从应用程序中抽象出来的作为存储文件夹。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM