需要using UnityEngine.UI;
然后就可以访问到CanvasScaler组件。
float width=GetComponent<CanvasScaler> ().referenceResolution.x
float height=GetComponent<CanvasScaler> ().referenceResolution.y
时间: 2024-10-14 07:55:59
需要using UnityEngine.UI;
然后就可以访问到CanvasScaler组件。
float width=GetComponent<CanvasScaler> ().referenceResolution.x
float height=GetComponent<CanvasScaler> ().referenceResolution.y