Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

How to center Input Field (old gui layout)

Discussion in 'Scripting' started by groch, May 15, 2015.

  1. groch

    groch

    Joined:
    Apr 7, 2015
    Posts:
    29
    Hi there,

    I want to center Input Field, so it would match any resolution. Thing is, it's an old GUI Layout, I can't use new GUI in that case, because script somehow saves text from that input without last letter. But anyway, here's how it looks like now:

    I want it to be like on the first screenshot (maybe a few milimeters to the right). What scrpit I should use?





     
  2. LeftyRighty

    LeftyRighty

    Joined:
    Nov 2, 2012
    Posts:
    5,148
    groch likes this.
  3. groch

    groch

    Joined:
    Apr 7, 2015
    Posts:
    29
    Can you show me how it would look like exactly? I am more a digital-painter than programist. :d

    I have something like that now:

    Code (CSharp):
    1. (new Rect(Screen.width * .10f, Screen.height * .13f, Screen.width * .57f, Screen.height * .55f));
    EDIT:

    Ok, I think I got it now. Scrpit looks like that:

    Code (CSharp):
    1. (new Rect(Screen.width / 2 - 125, Screen.height / 2 - 100, Screen.width / 1, Screen.height / 2));
    And the result:





    Thank You!!!
     
    Last edited: May 15, 2015