当前位置:网站首页>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 .
边栏推荐
- 【VCS+Verdi联合仿真】~ 以计数器为例
- Exploration of unity webgl
- 【VCS+Verdi聯合仿真】~ 以計數器為例
- Unity + hololens publishing settings
- Untiy3d controls scene screenshots through external JSON files
- Force buckle 349 Intersection of two arrays
- Chinese pycharm changed to English pycharm
- Pytorchcnn image recognition and classification model training framework
- Unity lens making
- Nestjs入门和环境搭建
猜你喜欢
![[learning notes] AssetBundle, xlua, hot update (use steps)](/img/59/9d9f31cfe55a908f2f0705e95ecc05.jpg)
[learning notes] AssetBundle, xlua, hot update (use steps)
![[note] usage model tree of the unity resource tree structure virtualizingtreeview](/img/3e/fe5610c797a14554ad735172c3ab54.jpg)
[note] usage model tree of the unity resource tree structure virtualizingtreeview

Create transfer generation point

MinGW-w64下载文件失败the file has been downloaded incorrectly!

Chinese pycharm changed to English pycharm

LXC 和 LXD 容器总结

Unity2019.3.8f1 development environment configuration of hololens2
![[notes] unity webgl input Chinese](/img/f7/805f510ff691227b4c2b529cc1099a.jpg)
[notes] unity webgl input Chinese

Records of problems encountered in unity + hololens development

Unity + hololens2 performance test
随机推荐
Unity camera control
Operation of JSON file
Special folders in unity3d and their meanings
【VCS+Verdi联合仿真】~ 以计数器为例
Unity + hololens common basic functions
Revit secondary development - use panel function without opening the project
Unity scroll view element drag and drop to automatically adsorb centering and card effect
[notes] unity Scrollview button page turning
Tcp/ip protocol details Volume I (Reading Guide)
Unit asynchronous jump progress
Create transfer generation point
Ripple effect of mouse click (unity & shader)
Unity ugui text value suspended enlarged display add text background
Chapter 11 advanced data management of OpenGL super classic (version 7)
Sourcetree usage
【VCS+Verdi聯合仿真】~ 以計數器為例
Pytorch的安装以及入门使用
Records of problems encountered in unity + hololens development
Nestjs configures static resources, template engine, and post examples
Intellj idea jars projects containing external lib to other project reference methods - jars