GUI Texture
2014-03-22 14:01
197 查看
GUI Texture
GUI Textures are displayed as flat images in 2D. They are made especially for user interface elements, buttons, or decorations. Their positioning and scaling is performed along the x and y axes only, and they are measuredin Screen Coordinates, rather than
World Coordinates.
The GUI Texture Inspector
Please Note: Unity 2.0 introduced
UnityGUI, a GUI Scripting system. You may prefer creating user interface elements with UnityGUI instead of GUI Textures. Read more about how to use UnityGUI in the
GUI Scripting Guide.
Properties
Texture | Reference to the Texture that will be used as the texture's display. |
Color | Color that will tint the Texture drawn on screen. |
Pixel Inset | Used for pixel-level control of the scaling and positioning of the GUI Texture. All values are measured relative to the position of the GUI Texture's Transform. |
X | Left-most pixel position of the texture. |
Y | Bottom-most pixel position of the texture. |
Width | Right-most pixel position of the texture. |
Height | Top-most pixel position of the texture. |
Left Border | Number of pixels from the left that are not affected by scale. |
Right Border | Number of pixels from the right that are not affected by scale. |
Top Border | Number of pixels from the top that are not affected by scale. |
Bottom Border | Number of pixels from the bottom that are not affected by scale. |
Details
To create a GUITexture:Select a Texture in the Project View
Choose GameObject->Create Other->GUI Texture from the menu bar
GUI Textures are perfect for presenting game interface backgrounds, buttons, or other elements to the player. Through scripting, you can easily provide visual feedback for different "states" of the texture -- when the mouse is hovering over
the texture, or is actively clicking it for example. Here is the basic breakdown of how the GUI Texture is calculated:
GUI Textures are laid out according to these rules
The GUI elements seen here were all created with GUI Textures
Borders
The number of pixels that will not scale with the texture at each edge of the image. As you rarely know the resolution your game runs in, chances are your GUI will get scaled. Some GUI textures have a border at the edge that is meant to be an exact numberof pixels. In order for this to work, set the border sizes to match those from the texture.
Pixel Inset
The purpose of the Pixel Inset is to prevent textures from scaling with screen resolution, and keeping thim in a fixed pixel size. This allows you to render a texture without any scaling. This means that players who run yourgame in higher resolutions will see your textures in smaller areas of the screen, allowing them to have more screen real-estate for your gameplay graphics.
To use it effectively, you need to set the scale of the GUI Texture's Transform to (0, 0, 0). Now, the
Pixel Inset is in full control of the texture's size and you can set the
Pixel Inset values to be the exact pixel size of your Texture.
Hints
The depth of each layered GUI Texture is determined by its individual Z Transform position, not the global Z position.GUI Textures are great for making menu screens, or pause/escape menu screens.
You should use Pixel Inset on any GUI Textures that you want to be a specific number of pixels for the width and height.
相关文章推荐
- iOS Foundation框架 -3.利用NSNumber和NSValue将非OC对象类型数据存放到集合
- VC编译出现“Internal error during IncrBuildImage”错误
- UIScrollview使用
- HDU 3998 Sequence (最长上升子序列+最大流)
- Fluid Shopping Website 开发阶段性总结——第一周
- SQL ExecuteNonQuery(), ExecuteScalar()返回值及DataAdapter
- VS2010 创建MFC工程报错 rcxdti.dll无法加载rcxdtiui.dll
- 让你明白response.sendRedirect()与request.getRequestDispatcher().forward()区别(转)
- 杭电ACM 1297 Children’s Queue
- 杭电ACM 1297 Children’s Queue
- 杭电ACM 1297 Children’s Queue
- android自动化测试中hierarchyviewer和uiautomatorviewer获取控件信息的方式比对(1)
- zImage和uImage的区别
- 在BBB启动时自动加载dtbo(或执行脚本、运行程序)
- android 事件处理机制之requestDisallowInterceptTouchEvent
- 让你明白response.sendRedirect()与request.getRequestDispatcher().forward()区别
- @QueryParam和@PathParam比较
- 可重入锁 ReentrantLock 源码解读 (2)锁框架 AbstractQueuedSynchronizer
- NGUI -- UITexture
- Building X10 from Source