- Home /
How to display new panel replacing the first one
I have created an application using unity3d and vuforia sdk. Whenever an image target is found a panel containing a number of button and information related to the image target can be viewed. I had been successful in displaying the information of the first image target, when I add the next image target the same information displays and I found a script to identify which information to display to said image target and it works perfectly fine. Now the next problem that I encounter is when I pressed the button of the Main Panel it displays the Info Panel which is the information is written however the main panel can still be seen behind the info panel. I've tried to set the SetActive(false) function of the game object but still doesn't work. Hoping someone can help me understand the problem, I know that it may be because of the Update() function but i don't know how to implement the change the changes..
Here's the code: NOTE: missionPanel is the Info Panel and btnPanel is the Main Panel
//This function is triggered when the Mission button is pressed and calls a new panel that displays the information
public void missionShow()
{
btnPanel.gameObject.SetActive (false);
txtPanel.SetActive (false);
missionPanel.SetActive (true);
visionPanel.SetActive (false);
}
//Basically this is the one that identifies which of the 2 image target is present during runtime
void Update()
{
StateManager sm = TrackerManager.Instance.GetStateManager();
IEnumerable<TrackableBehaviour> tbs = sm.GetActiveTrackableBehaviours();
foreach (TrackableBehaviour tb in tbs)
{
string name = tb.TrackableName;
ImageTarget it = tb.Trackable as ImageTarget;
Vector2 size = it.GetSize();
Debug.Log ("Active image target:" + name + " -size: " + size.x + ", " + size.y);
if (name == "HTC_Logo2")
{
btnPanel.SetActive (true);
txtScanning.text = "HTC Logo";
txtHint.text = "FOUND";
}
if (name == "CETELogo")
{
cetePanel.SetActive (true);
txtScanning.text = "CETE Logo";
txtHint.text = "FOUND";
}
}
}
Answer by jeck001 · Jan 22, 2018 at 12:36 PM
Write your code in OnTrackingFound in DefaultTrackableEventHandler instead of using Update function.