1. Spliteの高さ/幅の取得方法(※SpriteRendererが必要)
1 2 3 4 5 6 7 |
// 幅 float width = gameObject.GetComponent<SpriteRenderer>().bounds.size.x; print ("width: " + width); // 高さ float height = gameObject.GetComponent<SpriteRenderer>().bounds.size.y; print ("height: " + height); |
2. Planeの高さ/幅の取得方法
1 2 3 4 5 6 7 |
// 幅 float width = gameObject.GetComponent<Renderer>().bounds.size.x; print ("width: " + width); // 高さ float height = gameObject.GetComponent<Renderer>().bounds.size.y; print ("height: " + height); |
3. uGuiの高さ/幅の取得方法
1 2 3 4 5 6 7 |
// 幅 float width = gameObject.GetComponent<RectTransform>().sizeDelta.x; print ("width: " + width); // 高さ float height = gameObject.GetComponent<RectTransform>().sizeDelta.y; print ("height: " + height); |
0 Comments
1 Pingback