Script Component not Being detected by Vuforia's Default Trackable Event Handler Script
I have a Script Component named Start
inside a GameObject
named StartSpawn
and I am trying to run a function from Start
when the target is found but Unity/Visual Studio is not detecting the Start
script component. I even tried restarting both Unity and Visual Studio to only worsen the problem. When I opened both programs again and inspecting the code, the code I added was deleted and the script DefaultTrackableEventHandler.cs
was back to its original code. Btw, the function I'm calling to Instantiates a Prefab.
Here's the code inside the DefaultTrackableEventHandler.cs
:
protected virtual void OnTrackingFound()
{
if (mTrackableBehaviour)
{
var rendererComponents = mTrackableBehaviour.GetComponentsInChildren<Renderer>(true);
var colliderComponents = mTrackableBehaviour.GetComponentsInChildren<Collider>(true);
var canvasComponents = mTrackableBehaviour.GetComponentsInChildren<Canvas>(true);
//test
Start summoner = GetComponentInChildren<Start>();
// Enable rendering:
foreach (var component in rendererComponents)
component.enabled = true;
// Enable colliders:
foreach (var component in colliderComponents)
component.enabled = true;
// Enable canvas':
foreach (var component in canvasComponents)
component.enabled = true;
//test spawn
summoner.OnAppear();
}
}