Unity2d Screen.width 未在 Android 设备中返回 Canvas 面板实际屏幕尺寸

Unity2d Screen.width not returning Canvas panel actual screen dimensions in Android devices

我正在使用 LeanTween 移动方法将一个 canvas 面板水平导航到另一个面板。

我阅读了统一论坛,发现设置 RectTransform 值并使用 Screen.width 和高度是正确的方法。然而,当我 运行 设备 screen.width 中的这个没有按预期工作时。在不同的设备中,不同的行为。它不返回屏幕尺寸,我搜索了论坛,他们说 screen.width returns 游戏区域宽度。这是什么意思?

如何获得实际的 canvas 面板宽度?

Canvas 设置截图

在得到以下帮助后发布我自己的答案link

https://forum.unity3d.com/threads/ui-animate-fullscreen-panel-from-off-screen.271751/

gameObject.GetComponent().rect.width

gameObject.GetComponent().rect.height