Search Unity

  1. We've closed the job boards. If you're looking for work, or looking to hire check out Unity Connect. You can see more information here.
    Dismiss Notice
  2. Unity 2017.3 has arrived! Read about it here.
    Dismiss Notice
  3. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Make OnGUI Button To Auto Position according to screen Resolution.

Discussion in 'Extensions & OnGUI' started by Bakshinder_, Jan 13, 2018 at 1:02 PM.

  1. Bakshinder_

    Bakshinder_

    Joined:
    Dec 1, 2017
    Posts:
    58
    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!.