简体   繁体   English

iGUI for Unity 3D

[英]iGUI for Unity 3D

Well,I am working on my graduation project with unity 3d pro v4.5.0 ..I was using the normal method OnGUI() in my scripts but now i want to make a better interface for my project and i didn't anderstand how can i replace for example these lines in my "Database" Script: 好吧,我正在使用unity 3d pro v4.5.0进行毕业设计。..我在脚本中使用的是普通方法OnGUI(),但现在我想为我的项目提供更好的界面,而我并没有理解我在“数据库”脚本中替换了以下这些行:

            if (GUILayout.Button ("Add to database")) 
            {     
                    // Insert the data 
                    InsertRow (FirstName,LastName); 
                    // And update the readout of the database 
                    databaseData = ReadFullTable (); 

             } 

With just calling a Button1_click for example from my iGUI Class specially that every thing related to interface and buttons exists in OnGUI() method so how can i change all of that in my "Database" Script..i did anderstand how to make a button in iGUI that LOAD a scene or set an other function in the same iGUI Class but i just want to make buttons and iGUI field texts in iGUI MonoBehaviour Class and call them later whenever i need in my pricipal script "Database" if it is possible.Please am so in need for help. 例如,仅从我的iGUI类中仅调用Button1_click,与接口和按钮相关的所有事物都存在于OnGUI()方法中,因此我如何在我的“数据库”脚本中更改所有这些内容。我确实了解如何制作按钮在加载场景或在同一iGUI类中设置其他功能的iGUI中,但是我只想在iGUI MonoBehaviour类中创建按钮和iGUI字段文本,并在以后需要时在主脚本“数据库”中尽可能地调用它们。请急需帮助。 Thank you in advance. 先感谢您。

You need do this: 您需要这样做:

  1. create a public method in any script. 在任何脚本中创建一个公共方法。
  2. add the script to a GameObject. 将脚本添加到GameObject。
  3. Click the button and add the object with the script in the method OnClick located in the inspector. 单击按钮,然后在检查器中的OnClick方法中将对象与脚本一起添加。
  4. Choose your script and the public method where said No function. 选择您的脚本和公共方法,其中说没有功能。 Boala!!, when you click, your method run. Boala !!,当您单击时,您的方法将运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM