在unity3d中,如果你是使用的IGUI的话,那么当我们做一个GUI系统的时候,我们就会在iGUICode_xx.cs文件中进行有关的代码编写。但是一旦我的GUI系统十分复杂的时候就会出现让我们“疯狂”事情了,代码好庞大。
所以我们就需要对代码进行分离,把GUI系统划分一下。这个时候我们就希望在不同脚本中编辑相应的代码,这样下来我们的代码就没有那么复杂了。
在iGUI插件的之前版本是没有这样的功能的,那样我们就需要很特殊的处理了。现在都不想回忆那种繁琐的快感了!
在IGUI的最新版中就给我们提供这样的功能,现在介绍如下:
Multiple Roots
Attention : Multiple roots are in beta stage and only available after iGUI 1.2.4 and iGUIBasic 1.0.1
To create multiple roots follow these steps :
1) Create a scene.
2) Add a root.
3) Duplicate the root from hierarchy tab
4) Duplicate iGUICode_sceneName file
5) Change the file name to iGUICode_sceneName2 for example. Also change the class declaration, instance type and getInstance() return type to iGUICode_sceneName2.
6) Now drop the edited script file (iGUICode_sceneName2) to the “Manual code file” property of new root.
Now you’re ready to go. To edit gui elements, you have to enable only one root at a time and disable the ones which won’t be edited. You can enable/disable roots using the component checkbox (Please take a look at the figure right).