Event trigger on Image target Found and lost

0 votes
asked Feb 7 by intellify (260 points)
Hello any one can explain how to get event on Image target found and lost in EasyAR 3.1 Sdks ?

in last version there are method like found and lost but in new version i can't find anything .

1 Answer

0 votes
answered Feb 18 by rlmidiaalvs (2,420 points)
edited Feb 18 by rlmidiaalvs

Hello Intellify.

This code show whatever you want when target is lost or found.

// Assign to ImageTargetController to debug //

public ImageTargetController controllerName;

public ImageTargetController controllerName2;

// Assign to ImageTargetController to debug //

    private void Awake()
    {
        AddTargetControllerEvents(controllerName);
        AddTargetControllerEvents(controllerName2);
    }

    private void AddTargetControllerEvents(ImageTargetController controller)
    {
        if (!controller)
        {
            return;
        }

        controller.TargetFound += () =>
        {
            Debug.LogFormat("Found target {{id = {0}, name = {1}}}", controller.Target.runtimeID(), controller.Target.name());
        };
        controller.TargetLost += () =>
        {
            Debug.LogFormat("Lost target {{id = {0}, name = {1}}}", controller.Target.runtimeID(), controller.Target.name());
        };
    }

Welcome to EasyAR SDK Q&A, where you can ask questions and receive answers from other members of the community.
...