unity 2d 四大坐标系问题 鼠标点击位置问题 详细入门解析

本文详细解析Unity 2D中的四大坐标系,包括屏幕空间、视口空间、世界空间和GUI坐标系,并重点讲解如何从世界坐标转换到屏幕坐标,以及如何根据鼠标点击位置在Unity 2D场景中生成新物体。通过示例代码介绍了Unity的转换函数,如WorldToScreenPoint和ScreenToViewportPoint等。
摘要由CSDN通过智能技术生成





首先,unity2d中的camera有四大坐标系你需要了解清楚:

官方对unity camera的描述:


Description


A Camera is a device through which the player views the world.

A screen space point is defined in pixels. The bottom-left of the screen is (0,0); the right-top is (pixelWidth,pixelHeight). The z position is in world units from the camera.

A viewport space point is normalized and relative to the camera. The bottom-left of the camera is (0,0); the top-right is (1,1). The

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值