unity基础 (三)坐标系

一、屏幕坐标及视口坐标系

屏幕坐标系以左下角为原点 ,坐标单位为像素。

视口坐标系将相机视野的左下角定为 (0,0) ,右上角定为 (1,1),与分辨率无关。是百分比思维。

二、坐标转换

世界转本地

复制代码
世界转本地
        //this.transform.InverseTransformDirection
        //this.transform.InverseTransformPoint
        //this.transform.InverseTransformVector

本地转世界

复制代码
this.transform.TransformDirection
this.transform.TransformPoint  
this.transform.TransformVector

世界转屏幕

cs 复制代码
Camera.main.WorldToScreenPoint

屏幕转世界

cs 复制代码
Camera.main.ScreenToWorldPoint

世界转视口

cs 复制代码
Camera.main.WorldToViewportPoint

视口转世界

cs 复制代码
Camera.main.ViewportToWorldPoint

视口转屏幕

cs 复制代码
Camera.main.ViewportToScreenPoint

屏幕转视口

cs 复制代码
Camera.main.ScreenToViewportPoint;
相关推荐
平行云4 小时前
建筑BIM/3D可视化轻量级实时评审与分享方案
unity·ue5·3dsmax·实时云渲染·云桌面·云游戏·建筑bim
2501_915106321 天前
Windows 上开发 Unity iOS,使用 KXBuild 进行真机调试、性能采样与打包 ipa
windows·vscode·unity·ios·个人开发·swift·敏捷流程
FFFFujige1 天前
【Unity】一个的Dots用Ruhanka踩坑记录
unity·游戏引擎
wgslucky1 天前
Godot UI管理与使用
游戏引擎·godot
Oiiouui2 天前
Godot-GridGame架构屏幕UI层
架构·游戏引擎·godot
凯基迪科技2 天前
Unity游戏加密锁逆向方案、选型与攻防分析
游戏·unity·游戏引擎
阿松爱学习2 天前
【Unity开发】局部区域截图功能实现
unity·c#
淡海水2 天前
08-02-优化-LINQ与函数式编程的GC代价
unity·c#·.netcore·linq·gc
警醒与鞭策3 天前
Codex桌面版与Claude桌面版使用设置
android·unity·ai·性能优化
xcLeigh3 天前
Unity基础:Destroy与DestroyImmediate——正确销毁游戏物体的方式
游戏·unity·游戏引擎·教程