- Mastering UI Development with Unity
- Ashley Godbold
- 354字
- 2021-08-27 18:43:11
World Space
The last rendering mode is World Space. This mode allows you to render UI elements as if they are physically positioned within the world.
In Screen Space-Overlay and Screen Space-Camera, you cannot adjust the properties of the Rect Transform component. The positions of UI elements within Canvases with those two rendering modes do not translate to world space coordinates and are instead relative to the screen and camera. However, when a Canvas is in World Space render mode, the values of the Rect Transform can be adjusted, because the coordinates of the UI elements are based on actual positions within the scene. These Canvases do not have to face a specified camera as the other two Canvas types do.

This mode requests an Event Camera, rather than a Rendering Camera as Screen Space-Camera mode requested. An Event Camera is different than a Rendering Camera. Since this Canvas is in the World Space, it will be rendered with the Main Camera, just as all the other objects that exist within the scene. The Event Camera is the camera that will receive events from the EventSystem. So, if items on this Canvas require interactions, you have to include an Event Camera. If the player won't be interacting with the items on the Canvas, you can leave this blank.
The reason you need to specify an Event Camera is ray casting. When the user clicks on or touches the screen, a ray (one-directional line) is cast infinitely forward from the point of click (or touch) into the scene. The direction it points in is determined based on the direction the camera is facing. Most of the time, you will set this as your Main Camera, because that is the direction in which the player will expect the events to occur.
When you have World Space selected, the following properties become available:
- Event Camera: As stated earlier, the camera assigned to this slot determines which camera will receive the events of the Canvas
- Sorting Layer: This property is the same as in Screen Space-Camera
- Order in Layer: This property is the same as in Screen Space-Camera
- 計算思維與算法入門
- 案例式C語言程序設計
- 自己動手寫Java虛擬機
- Django Design Patterns and Best Practices
- Python機器學習:預測分析核心算法
- 區塊鏈技術進階與實戰(第2版)
- 響應式Web設計:HTML5和CSS3實戰(第2版)
- Serverless Web Applications with React and Firebase
- uni-app跨平臺開發與應用從入門到實踐
- Struts 2.x權威指南
- 跟戴銘學iOS編程:理順核心知識點
- The Statistics and Calculus with Python Workshop
- Sitecore Cookbook for Developers
- HTML5+jQuery Mobile移動應用開發
- 看漫畫學Python:有趣、有料、好玩、好用(全彩版)