- Sort Posts
- 5 replies
- Last post
Displaying splash screen when trackable is lost
It partly depends on how you are doing your splash screen, but typically you would do this as the first, possibly the only thing that you would do in the OnTrackingFound() method. The rest of the code in this method simply enables the children of the Image Target.
Assuming that you are using this method for a splash screen http://docs.unity3d.com/Documentation/Manual/HOWTO-SplashScreen.html then the code that needs to go in this method probably needs to enable / disable the object that has the splashscreen texture which will make it visible/invisible.
You might need to experiment with things a little to get it to work properly.
HTH
N
Displaying splash screen when trackable is lost
Thanks. So in the code. Where would I insert it exactly? I know...I know tough question.
/*==============================================================================
Copyright (c) 2012 QUALCOMM Austria Research Center GmbH.
All Rights Reserved.
Qualcomm Confidential and Proprietary
==============================================================================*/
using UnityEngine;
// A custom handler that implements the ITrackableEventHandler interface.
public class DefaultTrackableEventHandler : MonoBehaviour,
ITrackableEventHandler
{
#region PRIVATE_MEMBER_VARIABLES
private TrackableBehaviour mTrackableBehaviour;
#endregion // PRIVATE_MEMBER_VARIABLES
#region UNTIY_MONOBEHAVIOUR_METHODS
void Start()
{
mTrackableBehaviour = GetComponent<TrackableBehaviour>();
if (mTrackableBehaviour)
{
mTrackableBehaviour.RegisterTrackableEventHandler(this);
}
OnTrackingLost();
}
#endregion // UNTIY_MONOBEHAVIOUR_METHODS
#region PUBLIC_METHODS
// Implementation of the ITrackableEventHandler function called when the
// tracking state changes.
public void OnTrackableStateChanged(
TrackableBehaviour.Status previousStatus,
TrackableBehaviour.Status newStatus)
{
if (newStatus == TrackableBehaviour.Status.DETECTED ||
newStatus == TrackableBehaviour.Status.TRACKED)
{
OnTrackingFound();
}
else
{
OnTrackingLost();
}
}
#endregion // PUBLIC_METHODS
#region PRIVATE_METHODS
private void OnTrackingFound()
{
Renderer[] rendererComponents = GetComponentsInChildren<Renderer>();
// Enable rendering:
foreach (Renderer component in rendererComponents) {
component.enabled = true;
}
Debug.Log("Trackable " + mTrackableBehaviour.TrackableName + " found");
}
private void OnTrackingLost()
{
Renderer[] rendererComponents = GetComponentsInChildren<Renderer>();
// Disable rendering:
foreach (Renderer component in rendererComponents) {
component.enabled = false;
}
Debug.Log("Trackable " + mTrackableBehaviour.TrackableName + " lost");
}
#endregion // PRIVATE_METHODS
}
Displaying splash screen when trackable is lost
Hi mohvisuals,
If you look at any Image Target, you'll see that there is a DefaultTrackableEventHandler script attached to it. Then if you open this up in MonoDevelop you will be able to see the following methods:
OnTrackingFound()
OnTrackingLost()
This is where you can customise the behaviour, so you could use this to display whatever you like.
HTH
N
No here:
private void OnTrackingLost()
{
// Here
}
I think it would benefit you to spend half a day doing some basic scripting in Unity using one of their tutorials, as you will be in a better position to tweak things and understand where things might go wrong, and also it will help you to be more confident in trying things out and iterating.
HTH
N