using UnityEngine; using System.Collections; public class GameGUI : MonoBehaviour{ public GUIStyle customGUI; Rect ResizeGUI(Rect _rect){ float FilScreenWidth = _rect.width / 480; float rectWidth = FilScreenWidth * Screen.width; float FilScreenHeight = _rect.height / 320; float rectHeight = FilScreenHeight * Screen.height; float rectX = (_rect.x / 480) * Screen.width; float rectY = (_rect.y / 320) * Screen.height; Debug.Log(_rect.x+" - "+_rect.y); //Automatic resize font size customGUI.fontSize=(int)rectHeight/4; //Return new position and height return new Rect(rectX,rectY,rectWidth,rectHeight); } void OnGUI(){ GUI.Label(ResizeGUI(new Rect(190,60,100,100)), "Label position and size", customGUI); } }
Unity Automatic Resize OnGUI object
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
Silahkan