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

Using a Unity UI Textfield in a Button?

Discussion in 'UGUI & TextMesh Pro' started by JakeLeB, Mar 26, 2015.

  1. JakeLeB

    JakeLeB

    Joined:
    Apr 18, 2013
    Posts:
    25
    Hi, I've got a button to save a players name linked up to a Function:

    public void SaveUsername (string User) {
    Username = User;
    }

    How can I use the text entered in the Unity UI Textfield as User? Also I've noticed you can't link a button to a function with more than two requests, e.g.:

    public void Example (string Test, bool Test2) {
    stringEx = Test;
    GameObject.SetActive(Test2);
    }

    Is there a way around this?
     
  2. blizzy

    blizzy

    Joined:
    Apr 27, 2014
    Posts:
    775
    No. You need to use a wrapper function.

    Also, I think you meant "parameters" or "arguments," not "requests."
     
    JakeLeB likes this.
  3. JakeLeB

    JakeLeB

    Joined:
    Apr 18, 2013
    Posts:
    25
    It's alright now, after posting that I pretty much figured it out but decided to stick with using OnGUI instead. I did indeed, lack of sleep effects my wording. :p