Log in or register to post comments

Make a custom script that load after target image is found

July 27, 2018 - 9:53am #1

Hello,

 

I am new to working with Vuforia and I am sure this issue is probably a simple one but I cant figure out how to get my custom script to run after the target image is located. I have a custom script that is load my assets from a server but it is loaded immediately. I need it to only load after the target image is found.

My custom script is attached to an empty game object which is a child of the Image target. When the project is run, the asset loads right away and is not a child of the image target.

If anyone knows how to make this work, I would greatly appreciate the help

Make a custom script that load after target image is found

July 27, 2018 - 10:26am #2

By default, Vuforia doest turn your game object on and off it just turns the renderer so it just hides and shows the content, so your script will always run.  

You need to look at DefaultTrackableEventHandler script that's on your image target.  Edit the OnTrackingFound method.  A better long term solution (so you don't overwrite with updates) would be to subclass the DefaultTrackableEventHandler and  replace it on the image target.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Vuforia;
public class MyDefaultEventTrackable : DefaultTrackableEventHandler {
protected override void OnTrackingFound()
{
  base.OnTrackingFound ();
  // put logic here 
}
protected override void OnTrackingLost()
{
  base.OnTrackingLost ();
  //put logic here
}
}



 

 

Log in or register to post comments