public void ScreenUISelfAdptation(Transform scaleUI)
{
  float widthrate = UnityEngine.Screen.width / 1920.0f;
  float heightrate = UnityEngine.Screen.height / 1080.0f;
  float postion_x = scaleUI.GetComponent<RectTransform>().anchoredPosition.x * widthrate;
  float postion_y = scaleUI.GetComponent<RectTransform>().anchoredPosition.y * heightrate;
  scaleUI.localScale = new Vector3(widthrate, heightrate, 1);

  scaleUI.GetComponent<RectTransform>().anchoredPosition = new Vector2(postion_x, postion_y);
}

UnityEngine.Screen.width和UnityEngine.Screen.height是你要发布的屏幕分辨率大小。

1920.0f; x 1080.0f;是你制作UI时Game视图中的分辨率大小。

相关文章:

  • 2021-12-19
  • 2021-07-29
  • 2021-10-31
  • 2021-09-29
  • 2021-05-08
  • 2021-08-24
猜你喜欢
  • 2021-08-13
  • 2021-12-21
  • 2022-12-23
  • 2022-12-23
  • 2021-06-26
  • 2021-11-21
  • 2021-11-08
相关资源
相似解决方案