question:
when using ezgui, you may encounter the following problem: for buttona, in the inspector of the unity3d Editor, we can specify the methodtoinvoke (that is, the method name string) It presses. The response function here is the method buttonpushed () in the script2 script component of another gameobject (), if we want to pass the parameter when the button is pressed, ezgui cannot support it. Because it calls monobehavior invoke, its function prototype is: voidinvoke (stringmethodname, floattime ). So how should we pass parameters? For example, there is a script leveldata on buttona, and the script pressed by the processing button is mounted to the script2 of another gameobject. We want to pass a component named leveldata of buttona to script2.
Solution:
Modify the uimanager of ezguiSource code, As follows:
Public gameobject focusgameobject;
......
......
Case pointer_info.input_event.press:
If (physics. raycast (curptr. Ray, out hit, curptr. raydepth, curptr. layermask ))
{
/...
Focusgameobject = hit. collider. gameobject;
It is to add a Public Member to uimanager to record the gameobject corresponding to the currently pressed space. In our problem, it is actually buttona. In this way, the response in the button isCodeIn script2, you can do the following:
Public void buttonpushed ()
{
Leveldata whichlevel = uimanager. instance. focusgameobject. getcomponent <leveldata> ();
//...
}
So far, the problem has been solved, although there are some patches ~ _~