Log in or register to post comments

How does NGUI used on "IMAGE-TARGET"?

July 21, 2013 - 2:54am #1

How does NGUI used on "IMAGE-TARGET"?

I try to make a NGUI UI placed under IMAGE TARGET
The problem is NGUI will automatically show up on screen (Have not Target the image)

When Target the image then leaving the image, NGUI would not disappear.
It still show up on screen
May I ask how to solve?

How does NGUI used on "IMAGE-TARGET"?

February 12, 2014 - 12:58pm #3

Exactly what DavidBeard said.. It works but you also have to add the UICamera script to your "ARCamera" so it is using touch and click options and disable the other NGUI Camera from your 3D UI. Then add this to your DefaultTrackableEventHandler.cs script. Most of it should be there except the UIPanel parts.

    private void OnTrackingFound()
    {
        Renderer[] rendererComponents = GetComponentsInChildren<Renderer>(true);
        Collider[] colliderComponents = GetComponentsInChildren<Collider>(true);
        UIPanel[]  UIPanelComponents  = GetComponentsInChildren<UIPanel>(true);

        // Enable rendering:
        foreach (Renderer component in rendererComponents)
        {
            component.enabled = true;
        }

        // Enable colliders:
        foreach (Collider component in colliderComponents)
        {
            component.enabled = true;
        }

        // Enable UIPanel:
        foreach (UIPanel component in UIPanelComponents)
        {
            component.enabled = true;
        }

        Debug.Log("Trackable " + mTrackableBehaviour.TrackableName + " found");
    }


    private void OnTrackingLost()
    {
        Renderer[] rendererComponents = GetComponentsInChildren<Renderer>(true);
        Collider[] colliderComponents = GetComponentsInChildren<Collider>(true);
        UIPanel[]  UIPanelComponents  = GetComponentsInChildren<UIPanel>(true);

        // Disable rendering:
        foreach (Renderer component in rendererComponents)
        {
            component.enabled = false;
        }

        // Disable colliders:
        foreach (Collider component in colliderComponents)
        {
            component.enabled = false;
        }

        // Enable UIPanel:
        foreach (UIPanel component in UIPanelComponents)
        {
            component.enabled = false;
        }

        Debug.Log("Trackable " + mTrackableBehaviour.TrackableName + " lost");
    }

    #endregion // PRIVATE_METHODS
}

 

How does NGUI used on "IMAGE-TARGET"?

July 21, 2013 - 9:02am #2

I think that you'll need to add event handling for the NGUI component, similarly to how other child components of the ImageTarget are handled.

e.g. in DefaultTrackableEventHandler.cs

 

    private void OnTrackingFound()
    {
        Renderer[] rendererComponents = GetComponentsInChildren<Renderer>(true);
        Collider[] colliderComponents = GetComponentsInChildren<Collider>(true);

        // Enable rendering:
        foreach (Renderer component in rendererComponents)
        {
            component.enabled = true;
        }

        // Enable colliders:
        foreach (Collider component in colliderComponents)
        {
            component.enabled = true;
        }


        // add code to enable each NGUI UIPanel that is a child of the target

        Debug.Log("Trackable " + mTrackableBehaviour.TrackableName + " found");
    }

you'd also disable the panels in OnTrackingLost.

 

Log in or register to post comments