"We offer new support options and therefor the forums are now in read-only mode! Please check out our Support Center for more information." - Vuforia Engine Team

Timeout function with onTrackingBehavior extension

Hello. I'm trying to create a timeout screen in the main scene that drops you back into a static (non-vuforia) page after a certain amount of time. Right now I have it set to a certain time after the main scene is loaded. I need to be able to extend this time based on if the user is currently scanning targets. I tried pulling in the trackable behavior as an event that would start the clock from the last time that changed. However, I'm a scripting newb and am not doing so hot. I can't seem to get the OnTrackableStateChanged to run appropriately Any help is appreciated.

 

[code] using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement; using Vuforia; public class sceneManagement : MonoBehaviour { public float timeToIdle = 50.0f; //2 seconds float currentTime = 0f; float eventTime; public bool idle = true; void Start() { currentTime = Time.time + timeToIdle; mTrackableBehaviour = GetComponent(); } public void OnTrackableStateChanged( TrackableBehaviour.Status previousStatus, TrackableBehaviour.Status newStatus) { if (newStatus == TrackableBehaviour.Status.DETECTED || newStatus == TrackableBehaviour.Status.TRACKED || newStatus == TrackableBehaviour.Status.EXTENDED_TRACKED) { currentTime = Time.time + timeToIdle; } } void Update() { if (!idle) { checkIdle(); } } void checkIdle() { if (Time.time > currentTime || Time.time - eventTime > currentTime) { idle = true; Debug.Log("idling"); SceneManager.LoadScene("loading", LoadSceneMode.Single); } } public void loadMain() { SceneManager.LoadScene("main", LoadSceneMode.Single); } } [/code]