Forum Discussion

dlwnsl07's avatar
dlwnsl07
Copper Contributor
Nov 04, 2024

Does Hololens support compiling scripts on the fly?

I'm thinking of building a VR application using Unity (and I'm still a beginner).
Is it possible to generate new code while the user is using the VR application, and recompile it while the application is being run?

  • iu360's avatar
    iu360
    Copper Contributor

    Hello

    The Microsoft HoloLens, particularly when developing VR/AR applications using Unity, does not support "on-the-fly" compilation of scripts while the application is running. Unity uses a pre-compilation model, which means that any changes to scripts require stopping the application, recompiling the code, and redeploying the build. This limitation applies to maintaining performance and stability in VR environments.

    However, Unity provides alternatives like runtime script execution through C# scripting APIs and tools such as the Unity C# Interactive or the use of Lua for runtime scripting. These allow some dynamic behaviors, such as changing game object properties, without needing to stop the application. But these are generally limited to precompiled or preloaded script fragments, rather than full dynamic compilation.

    For more advanced scenarios, you can also explore Unity's Addressable Asset System, which allows you to load and manage assets dynamically at runtime. But for actual code generation and runtime compilation, HoloLens does not directly support it without third-party tools or frameworks.

Resources