반응형
Notice
Recent Posts
Recent Comments
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
Archives
Today
Total
관리 메뉴

Do Something IT

GUI - Scale GUIs According to Resolution 본문

Unity3D

GUI - Scale GUIs According to Resolution

아낙시만더 2017. 9. 13. 13:50
반응형
 void OnGUI()
 {
     GUI.DrawTexture(ResizeGUI(Rect(100, 100, 100, 100)), GuiTexture);
 }
 
 Rect ResizeGUI(Rect _rect)
 {
     float FilScreenWidth = _rect.width / 800;
     float rectWidth = FilScreenWidth * Screen.width;
     float FilScreenHeight = _rect.height / 600;
     float rectHeight = FilScreenHeight * Screen.height;
     float rectX = (_rect.x / 800) * Screen.width;
     float rectY = (_rect.y / 600) * Screen.height;
     
     return new Rect(rectX,rectY,rectWidth,rectHeight);
 }
반응형
Comments