问题
Unity3d - Vuforia-Unity: How to enable or disable a virtual button?
回答1:
Guess I found the solution myself!!
For Unity and Vuforia:
Approach #1:
As every entity in Unity is a GameObject, we can find virtual button using approach below:
To enable/disable a virtual button in C# script:
var myVirtualBtn = GameObject.Find("myVirtualButtonName"); // gameobject name above transform settings section
if(myVirtualBtn != null){
myVirtualBtn.GetComponent<VirtualButtonBehavior>().enabled = true; // Makes touchable virtual btn.
myVirtualBtn.GetComponent<VirtualButtonBehavior>().enabled = false; // Makes untouchable virtual btn.
}
Approach #2:
Skip registration of event handler associated with your virtual button
VirtualButtonBehaviour[] vbs = GetComponentsInChildren<VirtualButtonBehaviour>();
for( int i = 0; i< vbs.Length; ++i)
{
if(vbs[i].VirtualButtonName != "myVirtualButtonName") // Skip registration
vbs[i].RegisterEventHandler(this);
}
来源:https://stackoverflow.com/questions/51323819/unity3d-vuforia-unity-how-to-enable-or-disable-a-virtual-button