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_


    Dec 1, 2017
    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);
    6.         }
    Any help would be highly appreciated!.