一、屏幕坐标
世界坐标:transform.position,该物体在世界空间中的坐标
屏幕坐标:通过屏幕观察,该物体在屏幕上的位置。
屏幕坐标即主摄像机观察到的坐标,为Unity运行时出现的蓝色区域,y轴向上,x轴向右,左下角为(0, 0),宽度:Screen.width,高度:Screen.height,单位是像素。
int screenH = Screen.height;
int screenW = Screen.width; //大小可变,取决于窗口的实际大小。
Debug.Log("屏幕:" + screenH + "," + screenW);
获取一个物体的屏幕坐标:Camera.main.WorldToScreenPoint(worldPositon)
Vector3 worldPositon = transform.position;
Vector3 screenPositon = Camera.main.WorldToScreenPoint(worldPositon);
Debug.Log("世界坐标:" + worldPositon);
Debug.