TargetAbstractBehaviour Class¶
Description¶
TargetAbstractBehaviour is the base class for all TargetBaseBehaviours.
Public Properties¶
Public Events¶
Overwritten MonoBahaviour Functions¶
bool GameObjectActiveControl¶
Whether to use internal GameObject active control, for target show/hide.
The default behaviour of GameObjectActiveControl is,
protected virtual void Start()
{
if (gameObjectActiveControl)
gameObject.SetActive(false);
}
internal void OnTargetFound()
{
if (gameObjectActiveControl)
gameObject.SetActive(true);
}
internal void OnTargetLost()
{
if (gameObjectActiveControl)
gameObject.SetActive(false);
}
This is a piece of internal code, it just shows what EasyAR SDK is doing when GameObjectActiveControl is on, and it will not work in your code even if you paste it in your projects. If you need to handle more complicated case, follow instructions bellow.
So if you turn GameObjectActiveControl off, you can make things change as you like and gain more freedom of target show/hide control, by overwrite Start and implement OnTargetFound/OnTargetLost event handling. More specifically, you can achieve the internal behaviour when GameObjectActiveControl is off as below, which is quite similar of doing so in EasyAR SDK 1.x,
public class EasyImageTargetBehaviour : ImageTargetBehaviour
{
protected override void Awake()
{
base.Awake();
GameObjectActiveControl = false;
TargetFound += OnTargetFound;
TargetLost += OnTargetLost;
}
protected override void Start()
{
base.Start();
gameObject.SetActive(false);
}
void OnTargetFound(TargetAbstractBehaviour behaviour)
{
gameObject.SetActive(true);
}
void OnTargetLost(TargetAbstractBehaviour behaviour)
{
gameObject.SetActive(false);
}
}
event Action<TargetAbstractBehaviour> TargetFound¶
Target found event. Will be triggered when target is found in the scene.
event Action<TargetAbstractBehaviour> TargetLost¶
Target lost event. Will be triggered when target is lost in the scene.