纳金网

标题: [Unity 组件参考手册]桌面:图形用户界面脚本撰写指南 [打印本页]

作者: .    时间: 2013-2-18 17:14
标题: [Unity 组件参考手册]桌面:图形用户界面脚本撰写指南
Overview 概述GUI stands for Graphical User Interface. Unity's GUI system is called UnityGUI. UnityGUI allows you to create a huge variety of GUIs complete with functionality very quickly and easily. Rather than creating a GUI object, manually positioning it, and then writing a script that handles its functionality, you do all of this at once in a small amount of code. This works by creating GUI Controls, which are instantiated, positioned, and defined all at once.GUI是图形用户界面的英文简写。Unity的GUI系统被称作UnityGUI. UnityGUI能使你非常快捷简便的添加功能齐备且种类繁多的界面元素,通过在GUI控件的创建操作中同时包括实例化,定位和功能定义。使你只需要一次性写出很少量的代码就能同时完成创建一个GUI界面元素实例,并定位实例在屏幕的位置和描述界面元素被激活时所要执行的脚本三种工作For example, the following code will create a fully functional button from scratch:例如,执行下列代码将会从无到有的创建出一个功能齐备的按钮function OnGUI () {
if (GUI.Button (Rect (10,10,150,100), "I am a button")) {
  print ("You clicked the button!");
}
}这是通过执行以上代码创建的按钮
This is the button created by the code above 这是通过执行以上代码创建的按钮Although this example is very simple, there are very powerful and complex techniques available for use in UnityGUI. It is a broad subject, and the following sections will help you get up to speed as quickly as possible. This guide can be read straight through, or used as reference material.尽管这个例子非常简单,但在UnityGUI的应用过程中却能发展出非常强大和复杂的技术。关于这些技术应用会是一个很广泛的话题,接下来的章节将尽可能快的帮助你提高应用的能力。本指南能通过循序的方式进行阅读也能作为技术参考方便查阅
UnityGUI Basics GUI基础This section covers the important concepts of UnityGUI, giving you an overview as well as a bunch of working examples you can paste into your own projects. UnityGUI is very friendly to play with, so this is a good place to get started.这个章节将覆盖UnityGUI所有重要的方面。你可以从中获得一系列可以直接粘贴复制到你自己的工程中的可用例子的概述。UnityGUI很容易让这些例子运行起来,因此这里将是你入门最好的起点
Controls 控件This section lists every available Control in UnityGUI. It is complete with code examples and images.这个章节罗列出了所有在UnityGUI中可用的控件。均提供了完整的代码例子和图像讲解
Customization 自定义Creating functional GUI controls would not be as useful if their appearances couldn't be customized. Thankfully, we've thought of this. All controls in UnityGUI can be customized with GUIStyles and GUISkins. This section explains how to use them.如果在创建功能性GUI控件时不能自定义控件外观,那么将给我们带来多么无助的感觉。哦,感谢上帝,Unity想到了这点(。。。比我还煽情),UnityGUI中的所有控件都能使用GUIStyles和GUISkins完成自定义,我们将从这个章节发现如何使用它们。
Layout Modes 布局模式UnityGUI features two ways to arrange your GUIs. You can manually place each control on the screen, or you can use an Automatic Layout system which works a lot like HTML tables. Using one system or the other is as simple as using a different class, and you can mix the two together. This section explains the functional differences between the two systems, including examples.UnityGUI提供了两种方法使你可以排列界面中控件之间的位置。你能手工定义每个屏幕中的控件位置或者你也能通过一个类似HTML表格一样工作的自动布局系统来定位控件位置。使用一个系统或者只是简单的使用一个类,你可以把这两种方法组合在一起使用。这个章节将告诉你在这两种方法之间的功能差别,当然,还包括了例子
Extending UnityGUI 扩展UnityGUIUnityGUI is very easy to extend with new Control types. This chapter shows you how to make simple compound controls - complete with integration into Unity's event system.UnityGUI非常容易扩展出新的控件类型,这个章节将告诉你如何制作能和Unity事件系统完全适应和匹配的简单组合控件。
Extending Unity Editor 扩展Unity编辑器The main Unity editor is written using UnityGUI. It is completely extensible using the same code as you would use for in-game GUI. In addition, there are a bunch of Editor specific GUI widgets to help you out when creating custom editor GUI.Unity的主Editor界面是通过UnityGUI本身写成的。编写的代码形式和你制作游戏GUI时所使用的代码形式完全相同。如果你想要在Unity中制作自定义的Unity Editor GUI,Unity已为你准备好了一系列Editor 特定的GUI窗口小部件
【来源:互联网】
更多精彩教程,尽在web3D纳金网http://www.narkii.com/college/




欢迎光临 纳金网 (http://rs.narkii.com/club/) Powered by Discuz! X2.5