当前位置:网站首页>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 C trigonometric function, right triangle corner calculation
- Unity project hosting platform plasticscm (learn to use 2)
- Force buckle 59 Spiral matrix II
- 力扣977. 有序数组的平方
- Force buckle 704 Binary search
- 力扣27. 移除元素
- Singleton mode in unity
- Unity + hololens common basic functions
- Solution to the 292 week match of Li Kou
- Unrealeengine4 - about uobject's giant pit that is automatically GC garbage collected
猜你喜欢

【VCS+Verdi联合仿真】~ 以计数器为例

PWN Introduction (2) stack overflow Foundation

Unity packaging failure solution

Procedural animation -- inverse kinematics of tentacles

mmcv常用API介绍

Some problems encountered in unity steamvr

Li Kou 2049: count the number of nodes with the highest score

Rotation, translation and scaling of unity VR objects

Unity/ue reads OPC UA and OPC Da data (UE4)

One command to run rancher
随机推荐
How does unity use mapbox to implement real maps in games?
虚析构和纯虚析构
JPA composite primary key usage
2021-06-17 solve the problem of QML borderless window stretching, window jitter and flicker when stretching and shrinking
Force buckle 209 Minimum length subarray
【VCS+Verdi联合仿真】~ 以计数器为例
Passing values between classes using delegates and events
Some problems encountered in unity steamvr
Does the tester need to analyze the cause of the bug?
【VCS+Verdi聯合仿真】~ 以計數器為例
Steamvr causes abnormal scene camera
Unity 3D model operation and UI conflict Scrollview
Unity scroll view element drag and drop to automatically adsorb centering and card effect
炒美原油的国际交易平台如何能保障资金安全呢?
2021-03-16
QT connecting external libraries
Harbor API 2.0 query
Chinese pycharm changed to English pycharm
Revit Secondary Development - - Project use Panel features not opened
On mask culling of unity