Log in or register to post comments

Script Error ( The Best Overloaded method match & cannot convert)

August 21, 2015 - 3:54am #1

Hello master, i'm back and still so amateur in developing AR

I want my 3D object will play sound everytime my image target is detected, so i follow the script created by AlessandroB

public class ImageTargetPlayAudio : MonoBehaviour,
                                            ITrackableEventHandler
{
    private TrackableBehaviour mTrackableBehaviour;
 
    void Start()
    {
        mTrackableBehaviour = GetComponent<TrackableBehaviour>();
        if (mTrackableBehaviour)
        {
            mTrackableBehaviour.RegisterTrackableEventHandler(this);
        }
    }
     
    public void OnTrackableStateChanged(
                                    TrackableBehaviour.Status previousStatus,
                                    TrackableBehaviour.Status newStatus)
    {
        if (newStatus == TrackableBehaviour.Status.DETECTED ||
            newStatus == TrackableBehaviour.Status.TRACKED ||
            newStatus == TrackableBehaviour.Status.EXTENDED_TRACKED)
        {
            // Play audio when target is found
            audio.Play();
        }
        else
        {
            // Stop audio when target is lost
            audio.Stop();
        }
    }   
}

Then i get the best error which i dont get it on this part 

mTrackableBehaviour.RegisterTrackableEventHandler(this);

The error says

The Best Overloaded Method match for 'Vuforia.TrackableBehaviour.RegisterTrackableEventHandler(Vuforia.ITrackableEventHandler)' has some invalid argument

Argument '1' : cannot conver from 'ImageTargetPlayAudio' to 'Vuforia.ITrackableEventHandler'

Please help me, thank you in advance

Script Error ( The Best Overloaded method match & cannot convert)

July 30, 2016 - 1:17pm #4

mfahadminhas wrote:

dm3d wrote:

Did you include Vuforia before the class declaration?

using Vuforia;

public class ImageTargetPlayAudio : MonoBehaviour, ITrackableEventHandler
{
    ...
}

 

I am getting the same problem.
i have also included using Vuforia but still, is there any other method to do this?
I'm also attaching the error screen shot.

My mistake, the error was due to the wrong inherited class, it needed to be ITrackableBehaviour instead of ITrackerBehaviour.

Script Error ( The Best Overloaded method match & cannot convert)

July 30, 2016 - 1:12pm #3

dm3d wrote:

Did you include Vuforia before the class declaration?

using Vuforia;

public class ImageTargetPlayAudio : MonoBehaviour, ITrackableEventHandler
{
    ...
}

 

I am getting the same problem.
i have also included using Vuforia but still, is there any other method to do this?
I'm also attaching the error screen shot.

AttachmentSize
Image icon Error.JPG79.97 KB

Script Error ( The Best Overloaded method match & cannot convert

August 24, 2015 - 2:01pm #2

Did you include Vuforia before the class declaration?

using Vuforia;

public class ImageTargetPlayAudio : MonoBehaviour, ITrackableEventHandler
{
    ...
}

 

Log in or register to post comments