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.
Options

How to Build a holographic app that will also run on Windows desktop

Hi,

I am thinking of starting a holographic (3D) app project using C#/Unity. Since there is very few HoloLens devices out there, I am considering an option of creating a universal app that will run both on HoloLens and on other Windows devices at this point. (Same binary, or same codebase with minimal customization for each platform.)

(1) So, first of all, is it even possible?

(2) If so, what's the best practice?

Just to be clear, I can see that some types of holographic apps will not make sense outside HoloLens. But there are also types of apps that can be optimal on HoloLens and yet still can be usable on desktop or phone as well. (Many of the games, I imagine, belong to this category.)

Has anybody tried developing holographic apps for universal platforms?

Thanks,
~h

Best Answers

Answers

  • Options

    1) yes

    2) I don't think we have published best practices. I've honestly not tried to do this (except for the last few minutes :)).

    All that being said, I'm sure you've accidentally run on local machine instead of remote machine or emulator, and you probably noticed that the app works. You may not be able to move the camera on the local machine, but if you have a script that controls the camera with WASD, the camera will move.

    If I were going to try this, I would build and export two versions of my app from unity. One with enabled for VR/HoloLens checked and one that isn't. I know, not the best, but...the rendering and input profiles are going to be quite different anyway. If you do this then you can put HoloLens only code in #ifdef UNITY_HOLOGRAPHIC, and you can put the non-HoloLens code outside of these #ifdefs.

    ===
    This post provided as-is with no warranties and confers no rights. Using information provided is done at own risk.

    (Daddy, what does 'now formatting drive C:' mean?)

  • Options
    holodoctorholodoctor ✭✭
    edited July 2016

    Thanks, @Patrick. Let me try out what you suggest. ~h

  • Options
    JeromeJerome ✭✭

    check this:
    http://stackoverflow.com/questions/30479171/windows-10-uap-determine-if-device-is-iot-e-g-raspberry-pi-2
    and this
    https://forums.hololens.com/discussion/1048/analyticsinfo-deviceform-vs-apiinformation-istypepresent

    you should test at runtime if the device supports some functionalities and change the behavior of your app based on the result.

  • Options

    @Patrick, I tried your suggestion, but I couldn't make it work. For example, I tested this simple script attached to a cube.

    public class RotateCube : MonoBehaviour
    {
        Transform cube;
    
        void Start () {
            cube = GetComponent<Transform>();
        }
    
        void Update () {
    #if UNITY_HOLOGRAPHIC
            cube.Rotate(0.1f, 0.2f, 0.3f);
    #else
            // cube.Rotate(0.1f, 0.2f, 0.3f);
    #endif
        }
    
    }
    

    Unfortunately, the flag UNITY_HOLOGRAPHIC is never set in the generated VS project (under UWP) which includes this script regardless of the VR/Holographic player settings.

    Thanks,
    ~h

  • Options

    Thanks, @Jerome. I do have some experience building UWP apps, but I'm rather new to Unity-based app development.

    There are many issues to deal with when you develop an app for multiple platforms, but in terms of code branching/conditional compilation/build, there seem to be three options. To summarize what I have explored so far,

    (1) You can use the standard UWP techniques, as @Jerome suggests. For this, I think you will need to use NETFX_CORE or WINDOWS_UWP in Unity scripts. I couldn't figure out what are the differences between these two constants.
    (1A) You can check the value of VersionInfo.DeviceFamily. Apparently, this use is discouraged by Microsoft.
    (1B) The recommended way is using ApiInformation.IsTypePresent(). I am not sure how useful this will be, at least at this point without much Unity dev experience, since I will end up mostly programming in Unity API and I will not know generally how they are mapped to UWP API.

    (2) Per @Patrick's suggestion, I tried generating two VS apps (from the same Unity project) by changing the VR-enabled settings. This actually "works". Sort of. It enables/disabled the flag UNITY_HOLOGRAPHIC in the VS app projects, but not in the lib project where Unity asset scripts are included (Assembly-CSharp under the UWP folder). So, again, this option is not much useful to me.

    So far, I haven't found any optimal solution. Please let me know if anybody has a comment or a different suggestion.

    Thanks,
    ~h

  • Options

    Thanks for the input, @Patrick @Jerome.

Sign In or Register to comment.