当前位置:网站首页>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 .
边栏推荐
- Unity supports the platform # define instruction of script
- Force buckle 59 Spiral matrix II
- Revit secondary development - use panel function without opening the project
- Sourcetree usage
- 虚析构和纯虚析构
- JPA复合主键使用
- On mask culling of unity
- Unity3d position the model, rotate, drag and zoom around the model to obtain the center point of the model
- Records of some problems encountered during unity development (continuously updated)
- Unity packaging and publishing webgl error reason exception: failed building webgl player
猜你喜欢

Create transfer generation point

力扣209. 长度最小的子数组

mmcv常用API介绍

ParticleSystem in the official Manual of unity_ Collision module

Force buckle 59 Spiral matrix II

Unity project hosting platform plasticscm (learn to use 1)

Unity is associated with vs. there is a compiler problem when opening

力扣349. 两个数组的交集

Redis cluster concept

UE4 method of embedding web pages
随机推荐
Rotation, translation and scaling of unity VR objects
Unity limited time use limited trial time and use times
PWN入门(2)栈溢出基础
C # three ways to obtain web page content
0 foundation starts self-study unit notes control direction becomes larger
Records of some problems encountered during unity development (continuously updated)
Unity3d position the model, rotate, drag and zoom around the model to obtain the center point of the model
东塔攻防世界—xss绕过安全狗
力扣27. 移除元素
Pit of smoothstep node in shadergraph
Nestjs中控制器和路由的配置使用
[learning notes] AssetBundle, xlua, hot update (use steps)
ParticleSystem in the official Manual of unity_ Collision module
003-JS-DOM-Attr-innerText
Unity packaging failure solution
Solution to 293 problems in the week of Li Kou
Revit二次开发---未打开项目使用面板功能
Unity packaging and publishing webgl error reason exception: failed building webgl player
Unity publishing /build settings
pytorch中常用损失函数总结