Search Unity

Unity - Hololens: load file from OneDrive directory

Discussion in 'VR' started by marcozanetti, Jul 16, 2018.

  1. marcozanetti

    marcozanetti

    Joined:
    Jul 27, 2017
    Posts:
    2
    Hi
    I'm trying to develop a unity application for hololens and I need to load some 3D models at runtime.
    Recently I've discovered AssetBundle and I've been able to load a model at runtime, both from a local directory, both from a remote drive in the LAN only using a common PC.
    I've replicated same tests on Hololens but none of the has worked.

    I was thinking to use the OneDrive directory to save AssetBundle from a PC and load it at runtime inside Hololens, in order to use local directory in Hololens which is always synchronized; the problem I'm facing is that I don't know which is the path to the OneDrive directory in Hololens.

    Does anyone know which is OneDrive's directory? Alternatively how could I download a file from the OneDrive's account logged in Hololens?
     
  2. timke

    timke

    Joined:
    Nov 30, 2017
    Posts:
    408
    Hi marcozanetti,

    Developing on HoloLens is (mostly) just writing a specialized UWP app, and so I'd recommend looking at the Microsoft development sites for help with Windows features like OneDrive.

    Here are some threads from the HoloLens forums about accessing OneDrive:
    https://forums.hololens.com/discussion/1805/onedrive-unity
    https://forums.hololens.com/discussion/860/unity-retrieving-files-from-device

    These involve using the FileOpenPicker, but it's a place to start. However, I think you'll ultimately need to use the OneDrive SDK to accomplish what you want.

    Here are some resources to get you started:
    https://github.com/OneDrive/onedrive-sdk-csharp
    https://msdn.microsoft.com/en-us/magazine/mt632271.aspx?f=255&MSPPError=-2147217396

    Finally, you have to manually install OneDrive from the app store on HoloLens.
    I hope this helps.
     
  3. marcozanetti

    marcozanetti

    Joined:
    Jul 27, 2017
    Posts:
    2
    Thanks for your help timke.
    Finally I've solved the problem using FileOpenPicker, I had to struggle a bit because FilePicker operation are asynchronous but need to run on the UI in order to show the picker interface.

    Code (CSharp):
    1.  UnityEngine.WSA.Application.InvokeOnUIThread(async () =>
    2. {
    3. #if WINDOWS_UWP
    4.           //instantiate picker and get the file
    5. #endif
    6. }
    once I had the file handler I've put it in a byte[], after this I've used the AssetBundle.LoadFromMemory(byte[] fileStream);
    to retrieve the assset bundle and instantiate my game objects