I've been trying to invoke the native Hololens file picker via a button on a unity app (although I don't really know if it has one). I'm using MRTK in unity to build the app, and this is the code I'm currently using:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
#if ENABLE_WINMD_SUPPORT
using Windows.Storage;
using Windows.Storage.Streams;
#endif
public class OpenFilePicker : MonoBehaviour
{
public void OpenFile()
{
#if ENABLE_WINMD_SUPPORT
FilePicker();
#endif
}
private async void FilePicker()
{
#if ENABLE_WINMD_SUPPORT
var picker = new Windows.Storage.Pickers.FileOpenPicker();
picker.ViewMode = Windows.Storage.Pickers.PickerViewMode.Thumbnail;
picker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.PicturesLibrary;
picker.FileTypeFilter.Add(".jpg");
picker.FileTypeFilter.Add(".jpeg");
picker.FileTypeFilter.Add(".png");
await picker.PickSingleFileAsync();
#endif
}
}
Upon clicking the button, OpenFile()
is invoked. The code compiles and builds with no errors but fails to produce any result on the Hololens 2 emulator. I've been scouring the internet for information on how this is done but all I've found is this and a bunch of outdated posts.