Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Unity Mars Image Tracking

Discussion in 'Unity MARS' started by eyearth, Dec 15, 2020.

  1. eyearth

    eyearth

    Joined:
    Sep 27, 2018
    Posts:
    5
    When you trace the image, the child's script is called.

    private void Start()
    {
    _pyramid.gameObject.SetActive(true);
    }


    It goes well so far.

    But

    When I disable the pyramid and trace the image again, the script is not called.

    Can't I deactivate the child object if the camera loses the image?
     
    Last edited: Dec 15, 2020
  2. andysdds

    andysdds

    Joined:
    Aug 29, 2019
    Posts:
    11
    In Mars , they have a statue call
    Code (CSharp):
    1. MARSTrackingState
    can return the if camera lose the image or focus
     
  3. eyearth

    eyearth

    Joined:
    Sep 27, 2018
    Posts:
    5

    Can you tell me more about MARSTrackingState?
     
  4. andysdds

    andysdds

    Joined:
    Aug 29, 2019
    Posts:
    11
    Inside MARSSession script have a variable call "m_Subscriber" , it is a IProvidesMarkerTracking .
    Now , you can subscribe you custom action using "SubscribeMarkerUpdated" with m_Subscriber .
    like this
    Code (CSharp):
    1. Action<MRMarker> customUpdateEvent;
    2.  
    3. customUpdateEvent = (MRMarker marker) =>
    4. {
    5. marker.trackingState // <= this is the state
    6.  
    7. };
    8.  
    9. m_Subscriber.SubscribeMarkerUpdated (customUpdateEvent);
    You can check the trackingState with MARSTrackingState , and you can do the magic.