Search Unity

Make OnGUI Button To Auto Position according to screen Resolution.

Discussion in 'Immediate Mode GUI (IMGUI)' started by HBK_, Jan 13, 2018.

  1. HBK_

    HBK_

    Joined:
    Dec 1, 2017
    Posts:
    87
    Hi everyone,i have a Repeat Type OnGUI Button in a script and on unity's player it shows my button exactly where i wanted it to but on devices with other resolution it doesn't show the button where i placed it i wanna make my OnGUI Button to reposition itself on other devices with different resolution to that place where it was placed before.......any idea how to do that? here's the snipped of that button code:
    Code (CSharp):
    1.         if (GUI.RepeatButton (new Rect (leftcontrolright, leftcontrolup, leftcontrolxsize, leftcontrolysize), "move left")){
    2.             Vector3 v3Force = thrust * -transform.right;
    3.             rb.AddForce(v3Force);
    4.  
    5.  
    6.         }
    Any help would be highly appreciated!.