Author Topic: [SOLVED] how to get the Field text from buttton (ngui login form)  (Read 2070 times)

xboysite

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 2
    • View Profile
My project structure is



Following script is attached with Login button



How to access the texts entered at Username and Password Field from my custom script (MyButtom.cs) which is attached to Login Button?????

help me with proper code example to understand the logic behind this to do.  :)
« Last Edit: July 06, 2014, 04:41:49 AM by xboysite »

xboysite

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 2
    • View Profile
Re: [SOLVED] how to get the Field text from buttton (ngui login form)
« Reply #1 on: July 06, 2014, 04:44:42 AM »
easier way to access field text is by

  1.  
  2. public class MyButton : MonoBehaviour {
  3.  
  4.         public Transform user;
  5.         public Transform pass;
  6.  
  7.         void OnClick(){
  8.  
  9.                 Debug.Log ("username: "+ user.GetComponent<UIInput>().text +" password: "+ pass.GetComponent<UIInput>().text);
  10.         }
  11. }
  12.  
  13.  

PoN

  • Full Member
  • ***
  • Thank You
  • -Given: 1
  • -Receive: 4
  • Posts: 111
    • View Profile
Re: [SOLVED] how to get the Field text from buttton (ngui login form)
« Reply #2 on: July 06, 2014, 09:12:12 PM »
i think is a better way, that to create refs an UIInput component , instead of Transform then get a property - value,

  1. public UIInput userField;
  2. public UIInput passField;
  3.  
  4. void OnClick()
  5. {
  6.      Debug.Log("username: " +userField.value + " password: " +passField.value);
  7. }
  8.  
Worked on Doc&DogAge Of Fury 3D. Actually working on WarMach.