Author Topic: Selecting UIInput via code  (Read 2347 times)

Groszq

  • Guest
Selecting UIInput via code
« on: June 21, 2013, 01:14:00 AM »
Hi there!

I need to activate UIInput via code to make a system of Private Message, Offer trade and etc. in the game, which Im woking on. Is there any possibility to create something like that?

I use UIInput.selected property, but it still doesn't work properly.

  1.                 selectedChannel.transform.FindChild("InputField").GetComponent<UIInput>().label.text = "/whisper " + playerName + " ";
  2.                 selectedChannel.transform.FindChild("InputField").GetComponent<UIInput>().selected = true;

Thanks in advance!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Selecting UIInput via code
« Reply #1 on: June 21, 2013, 02:53:45 AM »
1. Never use Find. Bad practice, slow, and is based on name -- something that you can easily change without thinking.

2. Look at the chat example that comes with NGUI. Pressing Enter activates input there.