Search Unity

  1. Get all the Unite Berlin 2018 news on the blog.
    Dismiss Notice
  2. Unity 2018.2 has arrived! Read about it here.
    Dismiss Notice
  3. Improve your Unity skills with a certified instructor in a private, interactive classroom. Learn more.
    Dismiss Notice
  4. ARCore is out of developer preview! Read about it here.
    Dismiss Notice
  5. Magic Leap’s Lumin SDK Technical Preview for Unity lets you get started creating content for Magic Leap One™. Find more information on our blog!
    Dismiss Notice
  6. 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.

  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!.