像素点之间的距离 转换为 厘米

预备知识

DPI(Dots Per Inch) :每英寸的像素点数目。
Screen.dpi 返回当前物理设备的dpi。
1英寸2.54厘米

测试

void PrintLength(float pixelLength)
{
    
    
    float inchNum = pixelLength / Screen.dpi;//像素转为英寸
    float inchToCm = inchNum * 2.54f;//英寸转为厘米
    Debug.Log($"{
      
      pixelLength}像素转为{
      
      inchToCm}厘米");
}

猜你喜欢

转载自blog.csdn.net/weixin_43796392/article/details/124610034
今日推荐