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

Create a dynamic Input Field

Discussion in 'UGUI & TextMesh Pro' started by joelm27, Feb 5, 2016.

  1. joelm27

    joelm27

    Joined:
    Feb 4, 2016
    Posts:
    32
    Hello

    I need an assistance how to create an input field dynamically, on the button click event.
    And it parent is cube.

    Thanks
     
  2. HankySpanky

    HankySpanky

    Joined:
    Feb 3, 2015
    Posts:
    77
    What exactly are you trying to achieve here? Is your UI canvas set in world space mode? Is the entire canvas parented under the cube?

    In any case, the generic answer would be that, when you do click on this button you speak of, you instantiate a new text field, then realign its position to where you see fit.

    Something along these lines:
    Code (CSharp):
    1. GameObject go = new GameObject(typeof(Text));
    2.  
    3. go.transform.parent = cube.transform.
    4.  
     
  3. joelm27

    joelm27

    Joined:
    Feb 4, 2016
    Posts:
    32
    What i want to achieve is to create a Input Field, on a certain Cube which i use for a placeholder for this particular Input field.. I hope you get my point....
    Thank you, hope to hear from you soon
     
  4. joelm27

    joelm27

    Joined:
    Feb 4, 2016
    Posts:
    32
    Am using unity 5
     
  5. HankySpanky

    HankySpanky

    Joined:
    Feb 3, 2015
    Posts:
    77
    Sorry. This isn't exactly soon.

    If I understand you correctly, you are trying to add an input field to your UI, and currently you have placed a square panel (this cube you speak of) where you want your input field to be?

    In any case, I recommend you have a look at this page if you haven't:
    http://docs.unity3d.com/Manual/script-InputField.html

    There's also this launching point for learning more about the UI system:
    https://unity3d.com/learn/tutorials/topics/user-interface-ui
     
  6. joelm27

    joelm27

    Joined:
    Feb 4, 2016
    Posts:
    32
    Thanks
     
  7. joelm27

    joelm27

    Joined:
    Feb 4, 2016
    Posts:
    32
    Now am working on the Resources.LoadAll, I will get back on UI later. I will check those links. Thanks