Hello I have a script accessing an instantiated game object of Vuforia from Hierarchy and adding a component to it:
IEnumerable tbs = TrackerManager.Instance.GetStateManager().GetTrackableBehaviours();
foreach (TrackableBehaviour tb in tbs)
{
if (tb.TrackableName == “Fashion”)
{
if (tb.name == “New Game Object”)
{
// change generic name to include trackable name
tb.gameObject.name = ++counter + “DynamicImageTarget-” + tb.TrackableName;
// add additional script components for trackable
tb.gameObject.AddComponent();
tb.gameObject.AddComponent();
Up to here it is working but at this point/line when i try to add
tb.gameObject.GetComponent().OnTargetFound.AddListener(DressFound);
is throwing null exception in runtime
When I try
tb.gameObject.GetComponent().OnTargetFound.RemoveAllListeners();
throwing null exception in runtime as well
However when i try
tb.gameObject.GetComponent().enable = false;
it is working and disabling script component
void DressFound()
{
augmentation.SetActive(true);
}
Why i can’t reach events on the script?