Apply parameters in ezgui in unity3d

Source: Internet
Author: User

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 ~ _~

 
 
 
 
 
 
       
 
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.