Can't use the new UI InputField?

I don’t know why but i can’t find any information about how to get the text from an InputField in unity, i want to get the text when the user finishes editing the Input field, can someone help please?

My answer is for Unity 4.6 using C#

  1. create an InputField and name it whatever you want, let’s say Foo

  2. you’ll need a script (can be added to the InputField, but I used a script attached to another object in my project)

  3. in that script, in the top line, add

    using UnityEngine.UI;
    and under public class … add

    public InputField Bar;
    (where Bar is the variable name)

  4. go to Hierarchy and select whichever object has that script attached to it; you will see Bar in the Inspector in the Script section - it will have an empty field to the right of it.

  5. Drag your InputField Foo from Hierarchy into that empty field next to Bar

  6. Test that it works:

    Debug.Log ("Bar = " + Bar.text);
    Bar.text = “Success”
    Debug.Log ("Bar = " + Bar.text);

Took many hours of trying and watching semi-relevant videos to figure this out.