hello
i want to touch a virtual button to create a GUIbutton with text "ship,see more info." on the phone screen .
here is my code
using UnityEngine; using System.Collections.Generic; public class VirtualButtonEventHandler : MonoBehaviour, IVirtualButtonEventHandler { private GameObject mship; void Start() { VirtualButtonBehaviour[] vbs = GetComponentsInChildren<VirtualButtonBehaviour>(); for (int i = 0; i < vbs.Length; ++i) { vbs[i].RegisterEventHandler(this); } mship = transform.FindChild("ship").gameObject; mship.active = true; } public void OnButtonPressed(VirtualButtonBehaviour vb) { switch (vb.VirtualButtonName) { case "vbname1": GUI.Box(new Rect(50,50,200,180), "Menu"); if(GUI.Button(new Rect(60,60,160,40), "ship,see more info.")) { Application.OpenURL("http://*****.com"); } break; case "vbname2": //waiting add; break; case "vbname3": //waiting add; break; }
but it doesn't works , when i touch the virtual button , the 3d model disappears!
can anyone help? thanks very much!!
I believe GUI methods can only be called from the OnGUI callback:
http://unity3d.com/support/documentation/ScriptReference/MonoBehaviour.OnGUI.html
- Kim