【发布时间】:2021-10-14 07:35:14
【问题描述】:
我一直在尝试通过一个统一应用程序上的一个按钮来调用本机 Hololens 文件选择器(虽然我真的不知道它是否有一个)。我正在统一使用 MRTK 来构建应用程序,这是我目前正在使用的代码:
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
}
}
点击按钮后,OpenFile() 被调用。代码编译和构建没有错误,但未能在 Hololens 2 模拟器上产生任何结果。我一直在互联网上搜索有关如何完成此操作的信息,但我发现的只是这个和一堆过时的帖子。
【问题讨论】: