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. Join us on Dec 8, 2022, between 7 am & 7 pm EST, in the DOTS Dev Blitz Day 2022 - Q&A forum, Discord, and Unity3D Subreddit to learn more about DOTS directly from the Unity Developers.
    Dismiss Notice
  3. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

Question Acces InputField from Script

Discussion in 'UGUI & TextMesh Pro' started by Thomas_DK, Sep 14, 2022.

  1. Thomas_DK


    Feb 1, 2018
    Hi there,
    I am trying to acces the text from an InputField which is a child.
    --- Hirachy --------
    - InputCanvas
    -- Image <Image>
    -- MathInput <InputField>
    -- Math <Text>

    I can acces the Math<Text> Propertie with the following:
    Code (CSharp):
    2. GameObject InputCanvas;
    3. InputCanvas = GameObject.Find("InputCanvas");
    5. Transform textTr = InputCanvas.transform.Find("Math");
    6. Text mathText = textTr.GetComponent<Text>();
    7. mathText.text = "This is my Text";
    But so far I have had no luck accesing the text which is in the InputFields Text property.

    Any Help would be greatly appriciated!

    Best wishes