Hey there everyone, I’m new to Unity but do have a background from backend web development. That aside, I’m having issues with trying to instantiating the ARSession on my app on a button press. Even though in Inspector, I’ve already assigned the ARSession object, in the script itself it returns itself as Null, so I just don’t get it. May I know what I’m doing wrong, please?
(Please do ignore the other properties… they are there for temporary/testing for now)
The code in question:
Error log when pressing on the button:
2023/07/17 22:59:30.532 19310 19368 Info Unity ToggleCamera() called!
2023/07/17 22:59:30.532 19310 19368 Info Unity Function:ToggleCamera()
2023/07/17 22:59:30.532 19310 19368 Info Unity UnityEngine.Events.UnityEvent:Invoke()
2023/07/17 22:59:30.532 19310 19368 Info Unity UnityEngine.EventSystems.ExecuteEvents:Execute(GameObject, BaseEventData, EventFunction`1)
2023/07/17 22:59:30.532 19310 19368 Info Unity UnityEngine.InputSystem.UI.InputSystemUIInputModule:ProcessPointerButton(ButtonState&, PointerEventData)
2023/07/17 22:59:30.532 19310 19368 Info Unity UnityEngine.InputSystem.UI.InputSystemUIInputModule:ProcessPointer(PointerModel&)
2023/07/17 22:59:30.532 19310 19368 Info Unity UnityEngine.InputSystem.UI.InputSystemUIInputModule:Process()
2023/07/17 22:59:30.532 19310 19368 Info Unity UnityEngine.EventSystems.EventSystem:Update()
2023/07/17 22:59:30.532 19310 19368 Info Unity
2023/07/17 22:59:30.535 19310 19368 Info Unity ToggleCamera() called! camera start
2023/07/17 22:59:30.535 19310 19368 Info Unity Function:ToggleCamera()
2023/07/17 22:59:30.535 19310 19368 Info Unity UnityEngine.Events.UnityEvent:Invoke()
2023/07/17 22:59:30.535 19310 19368 Info Unity UnityEngine.EventSystems.ExecuteEvents:Execute(GameObject, BaseEventData, EventFunction`1)
2023/07/17 22:59:30.535 19310 19368 Info Unity UnityEngine.InputSystem.UI.InputSystemUIInputModule:ProcessPointerButton(ButtonState&, PointerEventData)
2023/07/17 22:59:30.535 19310 19368 Info Unity UnityEngine.InputSystem.UI.InputSystemUIInputModule:ProcessPointer(PointerModel&)
2023/07/17 22:59:30.535 19310 19368 Info Unity UnityEngine.InputSystem.UI.InputSystemUIInputModule:Process()
2023/07/17 22:59:30.535 19310 19368 Info Unity UnityEngine.EventSystems.EventSystem:Update()
2023/07/17 22:59:30.535 19310 19368 Info Unity
2023/07/17 22:59:30.537 19310 19368 Info Unity 1000
2023/07/17 22:59:30.537 19310 19368 Info Unity Function:ToggleCamera()
2023/07/17 22:59:30.537 19310 19368 Info Unity UnityEngine.Events.UnityEvent:Invoke()
2023/07/17 22:59:30.537 19310 19368 Info Unity UnityEngine.EventSystems.ExecuteEvents:Execute(GameObject, BaseEventData, EventFunction`1)
2023/07/17 22:59:30.537 19310 19368 Info Unity UnityEngine.InputSystem.UI.InputSystemUIInputModule:ProcessPointerButton(ButtonState&, PointerEventData)
2023/07/17 22:59:30.537 19310 19368 Info Unity UnityEngine.InputSystem.UI.InputSystemUIInputModule:ProcessPointer(PointerModel&)
2023/07/17 22:59:30.537 19310 19368 Info Unity UnityEngine.InputSystem.UI.InputSystemUIInputModule:Process()
2023/07/17 22:59:30.537 19310 19368 Info Unity UnityEngine.EventSystems.EventSystem:Update()
2023/07/17 22:59:30.537 19310 19368 Info Unity
2023/07/17 22:59:30.539 19310 19368 Info Unity 2000
2023/07/17 22:59:30.539 19310 19368 Info Unity Function:ToggleCamera()
2023/07/17 22:59:30.539 19310 19368 Info Unity UnityEngine.Events.UnityEvent:Invoke()
2023/07/17 22:59:30.539 19310 19368 Info Unity UnityEngine.EventSystems.ExecuteEvents:Execute(GameObject, BaseEventData, EventFunction`1)
2023/07/17 22:59:30.539 19310 19368 Info Unity UnityEngine.InputSystem.UI.InputSystemUIInputModule:ProcessPointerButton(ButtonState&, PointerEventData)
2023/07/17 22:59:30.539 19310 19368 Info Unity UnityEngine.InputSystem.UI.InputSystemUIInputModule:ProcessPointer(PointerModel&)
2023/07/17 22:59:30.539 19310 19368 Info Unity UnityEngine.InputSystem.UI.InputSystemUIInputModule:Process()
2023/07/17 22:59:30.539 19310 19368 Info Unity UnityEngine.EventSystems.EventSystem:Update()
2023/07/17 22:59:30.539 19310 19368 Info Unity
2023/07/17 22:59:30.540 19310 19368 Info Unity Null
2023/07/17 22:59:30.540 19310 19368 Info Unity Function:ToggleCamera()
2023/07/17 22:59:30.540 19310 19368 Info Unity UnityEngine.Events.UnityEvent:Invoke()
2023/07/17 22:59:30.540 19310 19368 Info Unity UnityEngine.EventSystems.ExecuteEvents:Execute(GameObject, BaseEventData, EventFunction`1)
2023/07/17 22:59:30.540 19310 19368 Info Unity UnityEngine.InputSystem.UI.InputSystemUIInputModule:ProcessPointerButton(ButtonState&, PointerEventData)
2023/07/17 22:59:30.540 19310 19368 Info Unity UnityEngine.InputSystem.UI.InputSystemUIInputModule:ProcessPointer(PointerModel&)
2023/07/17 22:59:30.540 19310 19368 Info Unity UnityEngine.InputSystem.UI.InputSystemUIInputModule:Process()
2023/07/17 22:59:30.540 19310 19368 Info Unity UnityEngine.EventSystems.EventSystem:Update()
2023/07/17 22:59:30.540 19310 19368 Info Unity
2023/07/17 22:59:30.542 19310 19368 Info Unity 3000
2023/07/17 22:59:30.542 19310 19368 Info Unity Function:ToggleCamera()
2023/07/17 22:59:30.542 19310 19368 Info Unity UnityEngine.Events.UnityEvent:Invoke()
2023/07/17 22:59:30.542 19310 19368 Info Unity UnityEngine.EventSystems.ExecuteEvents:Execute(GameObject, BaseEventData, EventFunction`1)
2023/07/17 22:59:30.542 19310 19368 Info Unity UnityEngine.InputSystem.UI.InputSystemUIInputModule:ProcessPointerButton(ButtonState&, PointerEventData)
2023/07/17 22:59:30.542 19310 19368 Info Unity UnityEngine.InputSystem.UI.InputSystemUIInputModule:ProcessPointer(PointerModel&)
2023/07/17 22:59:30.542 19310 19368 Info Unity UnityEngine.InputSystem.UI.InputSystemUIInputModule:Process()
2023/07/17 22:59:30.542 19310 19368 Info Unity UnityEngine.EventSystems.EventSystem:Update()
2023/07/17 22:59:30.542 19310 19368 Info Unity
2023/07/17 22:59:30.545 19310 19368 Info Unity Null
2023/07/17 22:59:30.545 19310 19368 Info Unity Function:ToggleCamera()
2023/07/17 22:59:30.545 19310 19368 Info Unity UnityEngine.Events.UnityEvent:Invoke()
2023/07/17 22:59:30.545 19310 19368 Info Unity UnityEngine.EventSystems.ExecuteEvents:Execute(GameObject, BaseEventData, EventFunction`1)
2023/07/17 22:59:30.545 19310 19368 Info Unity UnityEngine.InputSystem.UI.InputSystemUIInputModule:ProcessPointerButton(ButtonState&, PointerEventData)
2023/07/17 22:59:30.545 19310 19368 Info Unity UnityEngine.InputSystem.UI.InputSystemUIInputModule:ProcessPointer(PointerModel&)
2023/07/17 22:59:30.545 19310 19368 Info Unity UnityEngine.InputSystem.UI.InputSystemUIInputModule:Process()
2023/07/17 22:59:30.545 19310 19368 Info Unity UnityEngine.EventSystems.EventSystem:Update()
2023/07/17 22:59:30.545 19310 19368 Info Unity
2023/07/17 22:59:30.547 19310 19368 Info Unity 4000
2023/07/17 22:59:30.547 19310 19368 Info Unity Function:ToggleCamera()
2023/07/17 22:59:30.547 19310 19368 Info Unity UnityEngine.Events.UnityEvent:Invoke()
2023/07/17 22:59:30.547 19310 19368 Info Unity UnityEngine.EventSystems.ExecuteEvents:Execute(GameObject, BaseEventData, EventFunction`1)
2023/07/17 22:59:30.547 19310 19368 Info Unity UnityEngine.InputSystem.UI.InputSystemUIInputModule:ProcessPointerButton(ButtonState&, PointerEventData)
2023/07/17 22:59:30.547 19310 19368 Info Unity UnityEngine.InputSystem.UI.InputSystemUIInputModule:ProcessPointer(PointerModel&)
2023/07/17 22:59:30.547 19310 19368 Info Unity UnityEngine.InputSystem.UI.InputSystemUIInputModule:Process()
2023/07/17 22:59:30.547 19310 19368 Info Unity UnityEngine.EventSystems.EventSystem:Update()
2023/07/17 22:59:30.547 19310 19368 Info Unity
2023/07/17 22:59:30.555 19310 19368 Error Unity NullReferenceException: Object reference not set to an instance of an object.
2023/07/17 22:59:30.555 19310 19368 Error Unity at Function.ToggleCamera () [0x00000] in <00000000000000000000000000000000>:0
2023/07/17 22:59:30.555 19310 19368 Error Unity at UnityEngine.Events.UnityEvent.Invoke () [0x00000] in <00000000000000000000000000000000>:0
2023/07/17 22:59:30.555 19310 19368 Error Unity at UnityEngine.EventSystems.ExecuteEvents.Execute[T] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.ExecuteEvents+EventFunction`1[T1] functor) [0x00000] in <00000000000000000000000000000000>:0
2023/07/17 22:59:30.555 19310 19368 Error Unity at UnityEngine.InputSystem.UI.InputSystemUIInputModule.ProcessPointerButton (UnityEngine.InputSystem.UI.PointerModel+ButtonState& button, UnityEngine.EventSystems.PointerEventData eventData) [0x00000] in <00000000000000000000000000000000>:0
2023/07/17 22:59:30.555 19310 19368 Error Unity at UnityEngine.InputSystem.UI.InputSystemUIInputModule.ProcessPointer (UnityEngine.InputSystem.UI.PointerModel& state) [0x00000] in <00000000000000000000000000000000>:0
2023/07/17 22:59:30.555 19310 19368 Error Unity at UnityEngine.InputSystem.UI.InputSystemUIInputModule.Process () [0x00000] in <00000000000000