Author Topic: UIInput Modifiers  (Read 221 times)

Mazyod

  • Newbie
  • *
  • Thank You
  • -Given: 3
  • -Receive: 0
  • Posts: 8
    • View Profile
UIInput Modifiers
« on: January 09, 2017, 09:18:22 AM »
Hi,

In order for us to achieve proper Arabic text support in Unity, we use the ArabicSupport library, which just maps the arabic characters into the proper glyphs based on their positioning.

Now, instead of handling OnChange events on all UIInput instances, it would be great to have some sort of plugin system with modifiers (something like: delegate string Process(string s)).

For now, I have simply modified UIInput.cs and changed line 1378 to:
label.text = ArabicSupport.ArabicFixer.Fix(processed);

While thinking of a generalized use case, I realized that this feature could be extremely useful to handle text input, dealing with Emoji input and whatnot.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 330
  • -Receive: 1157
  • Posts: 22,084
  • Toronto, Canada
    • View Profile
Re: UIInput Modifiers
« Reply #1 on: January 13, 2017, 10:13:38 PM »
If you need an OnChange type event, consider having a custom input validator instead. If set, that delegate will be called as you're typing, letting you change the result freely.