Hello everyone.

The Mixed Reality Forums here are no longer being used or maintained.

There are a few other places we would like to direct you to for support, both from Microsoft and from the community.

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.

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, or in our Microsoft Tech Communities forums at https://techcommunity.microsoft.com/t5/mixed-reality/ct-p/MicrosoftMixedReality.

And always feel free to hit us up on Twitter @MxdRealityDev.

Fundamental Question about saving data files on Hololens

I am sorry to keep asking this question or something similar but I have yet to find a satisfactory solution to this one. I am developing an Application based on Hololens. I have got to handle Unity as part of this process which presently supports C# 4.4 and no higher. I can add stuff to save XML files to HoloLens using just VS15 as the development platform. I could store and load them later using the HoloLens. However, when I went back to Unity to add more MonoBehaviour classes and change the infrastructure around, I found I was getting errors so that the 'building settings' could not progress. I have gone back to using standard file routines in a BackgroundWorker class except now I have a problem with opening KnownFolders which uses 'await' and 'async' commands. It seems to be a bit of a puzzle to me. I have OneDrive installed on HoloLens and I can share files with my PC but really don't know how to use it. I use the Windows Device Portal for uploading and viewing files and apps. It works great for a lot of stuff. I would like to see my saved data file on there and download it onto my PC later. If that were possible

Could anyone put me right on the best strategy to write and read data files here which is also compatible with Unity using the HoloLens please?

Best Answer

Answers

  • Thank you @HoloSheep for this reference. The blog is very informative and does highlight the problem I am facing at the moment. There is no doubt we are living at the beginning of an new era in computing and this device is at the forefront of it. I am expecting many changes and improvements to be made by Microsoft and partners. We have to expect changes and volatility and persist beyond that.

    I am going to follow the points of the blog and see if it makes a difference for me.

  • I was not able to access the StreamingAssets folder on Hololens. What did work is using the Windows Storage api. Then if you read or write files to Windows.Storage.ApplicationData.Current.LocalFolder.Path, you can access files from that folder in the Hololens web portal at LocalAppData \ AppName \ LocalState

  • In answer to @TimT I followed what @HoloSheep suggested. I went to the blog he suggested to Liv Erikson's page. Unfortunately it did not work for me yet . Perhaps I missed something and must give this a try again. However, I notice in the open discussions about the problems on

    https://forums.hololens.com/discussion/1860/new-unity-technical-preview-5-4-0f3-htp

    about using the 5.5beta version. I unfortunately went down this route first. I got most of what I wanted to do on Unity then I worked completely on VS15. I started with the 5.5.0b07 Unity beta which worked a treat up until I had to go back to Unity to make some adjustments. I found a lot of unwanted error reports. I delved into the Q & A comments more to find Microsoft recommended 5.40f3-HTP. So I installed that instead. I found that none of my existing code ran nor any of my backups either. Later it dawned on me that my existing work were all based on a 'more recent' version of Unity. This was a shame because I had to start over and build it up gradually. I still have an open question though about the way to load and save data files to HoloLens. I thought the 'StreamingAssets' would do it for me but unfortunately it didn't or not yet should I say. If I have an update on this, I assure you, I'll let you know.

  • @wheelchairman (and anyone who arrives at this thread looking info on saving files)

    like @TimT, my previous attempts to do something similar led me to posting the following solution a couple months back, however it sounded like you were looking for a Unity approach more along the lines of what Liz posted in her blog, I just have not had time to experiment with her code snippets as of yet.

    Windows Holographic User Group Redmond

    WinHUGR.org - - - - - - - - - - - - - - - - - - @WinHUGR
    WinHUGR YouTube Channel -- live streamed meetings

  • Dear @HoloSheep I think you may have pointed to the problem I have been having over the past few months. Now I haven't closely checked this out but this is where I see things.

    a) To use HoloLens and Unity in a harmonious way you have to make sure that Unity sees the code as the C# version 4.4. In this situation you can not have clauses like 'async, await and task'
    b) To use a filing based on Universal Windows Platform (UWP for short) on Unity you have to have access to asynchronous commands like 'async, await and task' which are available ONLY on C# version 5 and above.
    c) The only solution to this is to provide in the code snippets of conditional compilation like:-

    #if WINDOWS_UWP
    using Windows.Storage;
    using Windows.Storage.AccessCache;
    using Windows.Storage.Pickers;
    using Windows.Storage.Provider;
    using System.Threading.Tasks;
    using Windows.Data.Xml.Dom;
    #endif
    

    This will ensure no reported bugs in Unity and allow you to pass through this stage of C#4.4 compatibility for their on-board compiler to Visual Studio 15 where we can use the C#5 and C#6 commands outlined above.

    So if I ensure that everything I write that uses UWP procedures like:-

    #if WINDOWS_UWP
        static async public void read_lines()
        {
            if (readfile == null) return;
            dataset = await FileIO.ReadLinesAsync(readfile);
        }
    #endif
    

    should be ok provided that it links in with the Unity compatible code seamlessly. I am thinking that in the example above 'dataset' would have to be defined already to be an IList<System.String>.

    I would be most grateful if @HoloSheep or any other expert to comment on this please.

Sign In or Register to comment.