美文网首页
2020-08-17【Unity】世界坐标转相机坐标,用GUI显

2020-08-17【Unity】世界坐标转相机坐标,用GUI显

作者: 持刀的要迟到了 | 来源:发表于2020-08-17 19:48 被阅读0次

    一般用在ui上比较多。要让ui悬浮在物体上方,需要将物体坐标转换为ui坐标。
    https://blog.csdn.net/Stephanie_1/article/details/78132070

                Vector3 canvasScale = Camera.main.WorldToViewportPoint(x.data.roomObject.transform.position);
                //Debug.Log(canvasScale);
                //var resolution = Screen.resolutions[0];
                //Debug.LogError(resolution.width + " " + resolution.height);
    
                GUI.Label(new Rect(2560 * canvasScale.x, 1440 * (1 - canvasScale.y), 400, 400), s);
    

    相关文章

      网友评论

          本文标题:2020-08-17【Unity】世界坐标转相机坐标,用GUI显

          本文链接:https://www.haomeiwen.com/subject/pixcjktx.html