Search code examples
unity-game-enginevuforia

Set OnAutomaticHitTest and OnInteractiveHitTest during runtime


I'm placing my Plane Stage and Plane Finder and setting the attributes at runtime, but there are two attributes I can't figure out how to set: OnAutomaticHitTest and OnInteractiveHitTest.

I saw that it expects something of the type HitTestEvent, but i can't figure out how to set my custom function here.

Can someone Help me?


Solution

  • You can find the documentation for the PlaneFinderBehaviour here

    Essentially, you don't actually define these attribute but you use them to fire events.

    For example:

    public class CustomPlaneFinderBehaviour : PlaneFinderBehaviour
    {
        public void CustomIntPerformHitTest(Vector2 screenPosition)
        {
            //Triggered on interactive hit test
        }
        public void CustomAutoPerformHitTest(Vector2 screenPosition)
        {
            //Triggered on automatic hit test
        }
    }
    

    Then in the inspector you are able to define the events, by pressing the plus button and choosing the current script in the box. It then gives you the option to change the function that is called.

    Here on interactive hit test has been defined and automatic hit test has not:

    enter image description here