Author Topic: Linking Input to Button  (Read 4274 times)

TicTac

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 7
    • View Profile
Linking Input to Button
« on: October 06, 2013, 08:34:49 AM »
Hello, I'm new to NGUI  and Unity in general. I really like what I see with NGUI and I'm trying to sort out profiles for a game I'm developing but I am having problems. Basically what I wan't is for my Inputs from two text boxes to be sent to my create new profile script when a button is pressed. Currently I have a script on each input that reads content of each input, I was then trying to reference them using get component from my create profile but I'm struggling to do so. I feel like I'm missing a trick here! :)

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Linking Input to Button
« Reply #1 on: October 06, 2013, 10:16:21 PM »
Have a script like this on the button:
  1. public class MyHandler : MonoBehaviour
  2. {
  3.     public UIInput inputA;
  4.     public UIInput inputB;
  5.  
  6.     void OnClick()
  7.     {
  8.         Debug.Log(inputA.value + ", " + inputB.value);
  9.     }
  10. }
Don't forget to drag & drop the values in inspector after attaching this script to your button.

TicTac

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 7
    • View Profile
Re: Linking Input to Button
« Reply #2 on: October 07, 2013, 11:59:29 AM »
Cool, this looks like its working however I think because I am using the free version .value is not working? if so is there a way around it? I plan to update to the full version soon but for now it would be useful to have it working!

Darkmax

  • Jr. Member
  • **
  • Thank You
  • -Given: 2
  • -Receive: 1
  • Posts: 93
    • View Profile
Re: Linking Input to Button
« Reply #3 on: October 07, 2013, 12:35:27 PM »
I think instead of value is text