Unity-Technologies / arfoundation-samples

Example content for Unity projects based on AR Foundation
Other
3.07k stars 1.15k forks source link

systemStateChanged callback in Unity 2021.1 with ARFoundation 4.1.7 and XR Plugin Management 4.0.3 #834

Closed Maapel closed 3 years ago

Maapel commented 3 years ago

How can i implement systemStateChanged for AR subSystemManager in ARFoundation scripting. Thank You for the Help

tdmowrer commented 3 years ago

I'm not sure what you are asking. Are you looking for the ARSession.stateChanged event?

Maapel commented 3 years ago

Thank you so much for helping. It worked . If anyone wants how to do it here is an example this worked.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.XR.ARFoundation;
public class ARInteraction : MonoBehaviour
{

    void onChange(ARSessionStateChangedEventArgs eventArgs)
    {
        //Debug.Log(eventArgs.state);

    }

    void Start()
    {
        ARSession.stateChanged+= onChange;

    }

    void Update()
    {

    }
}