1
votes

I need to access the PicturesLibrary fodler on the Hololens. Docs state that you can do that by "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. I am using the Unity3D 2019.2 with .net 4.x

How can I load pictures from the folder the right way with the 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
1

1 Answers

1
votes

@crani have you set the UWP App Capability declaration for PicturesLibrary access?

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.

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.