Author Topic: UIInput On Change  (Read 3306 times)

Caio.Lib

  • Newbie
  • *
  • Thank You
  • -Given: 7
  • -Receive: 2
  • Posts: 26
    • View Profile
UIInput On Change
« on: February 27, 2014, 08:13:53 PM »
Hi!
I would like to know how can i use on change event from UI Input. Can i use it in the same way i can use on submit?
I'm doing a form when players can only continue after fill out the fields, but I'm using UI Button Keys to change controls and if player change control using arrow keys i don't receive on Submit event.
Thank you!

leung

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 3
    • View Profile
Re: UIInput On Change
« Reply #1 on: February 28, 2014, 07:28:55 AM »
Yes, I also want to know how to use onChange event

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIInput On Change
« Reply #2 on: February 28, 2014, 06:47:48 PM »
For whatever reason I can't seem to reply to this post with code. Don't know wtf is going on.

onChange is meant to be used as a notification that arrives when something changes, so if you wanted to have something like a sound that plays when you type, you'd set onChange to be your function.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIInput On Change
« Reply #3 on: February 28, 2014, 06:53:46 PM »
Ok, it looks like I can't use 'onChange' word in a post. Wtf. My hosting provider must have changed something again.
  1. UIInput input = GetComponent<UIInput>();
  2. input.onChanged = YourFunc;
...change 'onChanged' to 'onChange'

Caio.Lib

  • Newbie
  • *
  • Thank You
  • -Given: 7
  • -Receive: 2
  • Posts: 26
    • View Profile
Re: UIInput On Change
« Reply #4 on: February 28, 2014, 10:10:54 PM »
Could I ask you if you could show OnChange option in Unity Editor as you did with OnSubmit in next release? Just for simplicity!
Thank you again ArenMook!!
*English is not my first language.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIInput On Change
« Reply #5 on: March 01, 2014, 08:45:03 PM »
Ordinarily I would say I'd rather not, because OnChanged is meant to be used by developers, so exposing it in inspector would just create unnecessary clutter. However I've had this request a few times now so I'm beginning to consider it. How would you use it in your case?

Caio.Lib

  • Newbie
  • *
  • Thank You
  • -Given: 7
  • -Receive: 2
  • Posts: 26
    • View Profile
Re: UIInput On Change
« Reply #6 on: March 02, 2014, 12:36:46 AM »
Thank you! In my case i will use on change for:
- Change UI Input color: Red background for invalid ( empty ) value and white for valid.
- Change Play Button to enabled. [ I'm doing a form with two UI Inputs for players name. ]
- Save user input even if the players change controls by keys.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIInput On Change
« Reply #7 on: March 02, 2014, 06:45:25 PM »
Ah, yes I can certainly see it being useful then. Alright, I'll make it happen.

Caio.Lib

  • Newbie
  • *
  • Thank You
  • -Given: 7
  • -Receive: 2
  • Posts: 26
    • View Profile
Re: UIInput On Change
« Reply #8 on: March 03, 2014, 01:59:59 AM »
Thank you very much ArenMook!!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIInput On Change
« Reply #9 on: March 04, 2014, 12:12:25 AM »
It was a part of 3.5.3 btw.