Error when editing script on MacOS

  • Issue category: Unity
  • Host machine & OS version: M1 iMac (latest macOS)
  • Issue Environment : On Device
  • Xcode version: Latest
  • ARDK version: 1.3.1
  • Unity version:2021.3.2f1

Bug reproduction steps:

Make project (using vs 2022 preview and URP)
Import ARDK (I use a blank scene with a default camera in it, not the ARDK camera)
press play
edit script and save script
Error thrown:

UnityException: Internal_CreateGameObject is not allowed to be called from a MonoBehaviour constructor (or instance field initializer), call it in Awake or Start instead. Called from MonoBehaviour ‘_UpdateLoop’ on game object ‘update_loop’.
See “Script Serialization” page in the Unity Manual for further details.
UnityEngine.GameObject…ctor (System.String name, System.Type components) (at /Users/bokken/buildslave/unity/build/Runtime/Export/Scripting/GameObject.bindings.cs:377)
Niantic.ARDK.Utilities._UpdateLoop…cctor () (at Assets/ARDK/Utilities/_UpdateLoop.cs:36)
Rethrow as TypeInitializationException: The type initializer for ‘Niantic.ARDK.Utilities._UpdateLoop’ threw an exception.

This did not happen for me on my Windows machine

Hello Dylan,

Thank you for bringing this to our attention. We will look into it internally and see if we can find a solution.

In the meantime, could you please tell me what version of Visual Studio 2022 Preview you are using? And are you able to get around the error by using a different version, such as Visual Studio 2019 or the latest version of Visual Studio 2022?

The latest version, it was just updated.
I will try vs 2019 later today.
I doubt that will fix it as the error is thrown in Unity itself in play mode

Hello Dylan,

Thank you for your patience while we investigate this further.

ARDK relies on many things under the hood that aren’t serialized and don’t function well with hot-reloading of assemblies while in play mode. Because of this, we recommend for scripts to always be edited/refreshed outside of play mode to prevent such potential issues.