2

So it would appear that this would be a simple solution, but as I can not find any documentation on how to do exactly this it's effectively the same as brute-force guessing a password.

Environment

  • Unity Versions: 2019.3.1, 2019.3.4(current)
  • Platform: Universal Windows Platform
  • MRTK: 2.2, 2.3(current)
  • HoloLens 2 OS: Windows Holographic Operating System

What I Am Trying To Accomplish

  • I push a button and the file browser/explorer appears inside my Unity scene

The Problem

  • I can not launch the file browser/explorer in HoloLens 2.

Background/Context

With MRTK 2/HoloLens 2 you are able to launch external apps without exiting the Unity application. Something that HoloLens 1 could not do. Microsoft provides proof of this in their Unity examples package: Assets/MixedRealityToolkit.Examples/Demos/HandTracking/Scenes/HandInteraction.Examples.unity once you have loaded the .Foundation and .Examples external packages into your Unity project.

In the provided scene, out of all the presented object there are two buttons off to the right side that when pressed will launch the Edge Browser or the OS's settings application. This is accomplished with a launch URI attached script that runs .OpenURL on a string provided by the user via the GameObject's inspector.

GameObject inspector screenshot of the button that opens Edge Browser GameObject inspector screenshot of the button that opens Settings

And the code snippet (provided by Microsoft in MRTK2) that runs the user-inputted string:

public void Launch(string uri){
    ...
    Application.OpenURL(uri);
    ...
}


What I Have Tried So Far

Due to how similar Windows 10 on the Desktop and Windows Holographic Operating System is, when these buttons are pressed while Unity is in Play Mode, the buttons fully function, launching the computer's default browser, and the settings application for Windows 10.
Under this assumption I looked up how to open the file browser/explorer and am able to successfully launch it with the string explorer in the textbox, but only on the Windows 10 desktop. It does not work when running on HoloLens 2. Unsurprisingly, there are differences between Windows 10 and Windows Holographic Operating System, so testing this is slightly tedious as I need to build every time I need to test. So far the strings that I have tested are:
explorer explorer.exe ms-explorer ms-browser ms-storage ms-storage.storagefile:// (and without the ://) https://C:\
And so on....

Thinking that Application.OpenURL might not be the only/best route I have also tried a different script:

public void Opener(){
    System.Diagnostics.Process.Start("explorer.exe");
}

But once again, this approach works perfectly on Windows 10 Desktop, but not in HoloLens 2. I could keep on going with more examples and explanations but I'm already concerned I'll have to redefine this post as a Wikipedia article with the length it's already gotten to.

And that's about it. I'm stumped as to where to go from here. So while I continue to randomly shotgun into the Googleverse and see what half related snippets I can find to test and prove that they work on the Desktop and not HoloLens 2, thoughts/suggestions? I do not believe this is a complicated problem/solution. But it is a very specific one that, again as far as I can tell, has zero documentation on due to how new and scarce HoloLens 2 still is.

(Also I can't create a new tag for HoloLens 2, not good enough of a person. So for now I have to use the regular hololens tag)

bonzo
  • 312
  • 2
  • 4
  • 19

2 Answers2

2

I've been having some back-and-forth with Developer Support at Microsoft and they've been extremely helpful in revealing more information onto this subject, and we agreed that it'd be a good idea to document that on here in case someone comes across this need/issue in the future.



Currently there is no way to access the native file browser from within a Unity application on HoloLens 2. Before going 3rd party on a solution the best native course of action is to use FileOpenPicker:
https://learn.microsoft.com/en-us/windows/mixed-reality/app-model#file-pickers

Outside of fully native solutions, the next best course of action is to use a 3rd party asset from the asset store. Due to my developer environment/work restrictions I'm not confident I'll personally be able to use this method, but it is a viable course of action for most everyone else.

I'm considering this the official answer for the current state of HoloLens 2, but will be happy to revise this if the situation changes in the future.



tl;dr version:

Currently (early 2020) File Explorer is natively inaccessible from with an application, and the best/closest native solution is to use FileOpenPicker, or 3rd party assets on the Unity Asset Store.
bonzo
  • 312
  • 2
  • 4
  • 19
0

The native HoloLens file explorer is supported now.
It is just necessary to add this line of code:

UnityEngine.WSA.Application.InvokeOnUIThread()

For further information, have a look at this post:

System.Exception getting called when assessing OpenFilePicker on Hololens

fat
  • 6,435
  • 5
  • 44
  • 70