当前位置:网站首页>Unity3d get screen width and height
Unity3d get screen width and height
2022-06-30 05:11:00 【Shannan HSY】
A camera function is used here Camera.ViewportToWorldPoint, Unity The official definition is :
Camera.ViewportToWorldPoint Window to world position
function ViewportToWorldPoint (position : Vector3) : Vector3
Description describe
Transforms position from viewport space into world space.
From window space to world space .
Viewport space is normalized and relative to the camera. The bottom-left of the camera is (0,0); the top-right is (1,1). The z position is in world units from the camera.
Viewport space is normalized and relative to the camera , The bottom left of the camera is (0,0); The upper right is (1,1);Z The position of is the distance to the camera measured in world units .
Note that it transforms a x-y screen position, into a x-y-z position in 3D space.
Notice that it transforms a x-y Screen position to a 3D Spatial x-y-z Location .
You provide the function with a vector where the x-y components of the vector are the screen coordinates and the z component is the distance of the resulting plane from the camera.
This function takes the... In screen coordinates x-y Component vector , also z The component is at a distance from the plane generated by the camera .
After reading the official documents , Now we know how to get the actual width and height of the screen , Here is the sample code :
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
Got width And height Is the screen width and height , The meaning of the code has been clearly stated above .
边栏推荐
- Nestjs配置静态资源,模板引擎以及Post示例
- Output directory of log files after unity3d packaging
- ParticleSystem in the official Manual of unity_ Collision module
- Unity publishing /build settings
- Singleton mode in unity
- Unity3d position the model, rotate, drag and zoom around the model to obtain the center point of the model
- Rotation, translation and scaling of unity VR objects
- Revit二次开发---未打开项目使用面板功能
- Unity lens making
- Create transfer generation point
猜你喜欢
【VCS+Verdi联合仿真】~ 以计数器为例
【 VCS + Verdi joint simulation】 ~ Taking Counter as an Example
Unity C trigonometric function, right triangle corner calculation
Pytorch的安装以及入门使用
Unity script life cycle and execution sequence
The file has been downloaded incorrectly!
Intellj idea jars projects containing external lib to other project reference methods - jars
[notes] unity webgl input Chinese
Database base (Study & review for self use)
Preorder traversal of Li Kou 589:n fork tree
随机推荐
Draw on screen border in Commodore 64
Steamvr causes abnormal scene camera
Unity publishing /build settings
Does the tester need to analyze the cause of the bug?
Display steerable 3D model in front of unity UI
力扣704. 二分查找
Pit of smoothstep node in shadergraph
Under what conditions does the Z-index attribute expire?
力扣27. 移除元素
Ugui uses its own function to realize reverse mask
Unity/ue reads OPC UA and OPC Da data (UE4)
Unity supports the platform # define instruction of script
力扣977. 有序数组的平方
LXC 和 LXD 容器总结
Solution to the 292 week match of Li Kou
Pycharm database tool
One command to run rancher
Chapter 10 of OpenGL super classic (7th Edition) calculation shader
Nestjs中控制器和路由的配置使用
中文版PyCharm改为英文版PyCharm