Hello everyone.

We have decided to phase out the Mixed Reality Forums over the next few months in favor of other ways to connect with us.

The first way we want to connect with you is our mixed reality developer program, which you can sign up for at https://aka.ms/IWantMR.

The plan between now and the beginning of May is to clean up old, unanswered questions that are no longer relevant. The forums will remain open and usable.

On May 1st we will be locking the forums to new posts and replies. They will remain available for another three months for the purposes of searching them, and then they will be closed altogether on August 1st.

So, where does that leave our awesome community to ask questions? Well, there are a few places we want to engage with you. For technical questions, please use Stack Overflow, and tag your questions using either hololens or windows-mixed-reality. If you want to join in discussions, please do so in the HoloDevelopers Slack, which you can join by going to https://aka.ms/holodevelopers. And always feel free to hit us up on Twitter @MxdRealityDev.

How to Load File (pdf,jpg,etc) from HoloLens App

Hello,

I'm new in the world of app development with HoloLens and with UWP apps in general. I have basic training of C# and Unity, and started to know how works HoloLens in general.

I'm currently trying to develop a simple UI 2D app. The idea is to have 4 buttons which each of them opens a predefined file (pdf, jpg, etc).
The "app" works perfectly in Unity (I wrote a very simple script where a method called OpenURL opens a file with Applications.OpenURL). However, when I deploy it in the HoloLens it doesn't work - More specifically, The app crashes when I press any button.

At first, I thought that the reason may be that the HoloLens is trying to access a local path that it doesn't exist anymore in the HoloLens (The path C:/Users/... would not make sense in the HoloLens). I tried to use the Application.addPath to fix the issue (https://docs.unity3d.com/Manual/StreamingAssets.html) but it didn't work either.

After going in depth with this problem on Internet, I noticed that there are currently two ways of doing this:

  • Azure Microsoft
  • OneDrive
    The problem is that there's not much information about how to develop the coding or the steps that should be followed to do this. I tried to find coding about this but I still haven't found anything yet.

I wanted to ask the community if someone has developed an app that loads files directly from a local server or from other environments. In that case, would be possible to have some sort of explanation about how to do it?

I would very much appreciate your help since I have been some sort of frustrated with this. Also, I noticed this a persistent issue for many developers; so this could be a great way to definitely sort it out and close the topic

Thanks in advance!

Comments

  • Hi Nickrome,

    Your current approach will probably not work. Application.OpenURL is actually suspending your Unity app and opens the given URL in the system default webbrowser (could be Edge, Chrome, Firefox...) and brings it to the front.

    If I get you right, your goal is to load a remote resource (like a jpeg image) and display it inside the HoloLens Unity app.

    In this case:
    1. Take look at the WWW class in the Unity scripting API

    It comes with a simple but effective code example that loads a remote jpeg file and applies it to the texture of the material of a given GameObject.

    1. Make sure to set the correct Capabilites for HoloLens in the Player Settings: At least InternetClient is needed for this to work

    2. For Unity versions prior to 2018.2? there has been a bug when building with IL2CPP backend that prevented webrequests to work. Make sure to use .Net as scripting backend or use the most recent Unity Version

    One Last advice: For great UI/UX examples for HoloLens, check out the MixedRealityToolkit. It comes with lots of examples and prefabs like Buttons and Interactables that will instantly boost your development and gives your users an awesome experience.

    Cheers.

  • Hello The_XR_Guy,

    Thank you very much for the help. I'm currently facing other issues regarding the access of the files in a Web Server (made with Azure), but I this this option would work as soon as I fix the problem.

    I also wanted to ask if the pdf file would open the same way as a jpg file, or if is need to do something else.

    Best regards!

Sign In or Register to comment.