Author Topic: Extending UIInput  (Read 3322 times)

r-dotPhunky

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 4
    • View Profile
Extending UIInput
« on: October 08, 2013, 08:09:08 AM »
Hi ArenMook,

Back in July I asked this question regarding the NGUI license: http://www.tasharen.com/forum/index.php?topic=5022.msg24072#msg24072

Part of that answer was being told that inheriting from NGUI but not including NGUI was the way to go.  That made perfect sense when talking about creating controls using sprites, labels and inputs.

I'm working with the UIInput class.  I'm looking to keep all the functionality of the current UIInput class but add functionality to it.  So far I've been able to accomplish alot of what I want via adding scripts but I ran into a wall when trying to insert newly input text into an existing string in the UIInput field.  I've been trying to capture/move the new text in OnInputChanged but it seems as though I'm creating overhead when I should be working with Append in UIInput directly.

I can derive from UIInput and then implement what I need, but Append is private and I'd need to modify the NGUI source code to allow override which I'd like to avoid - thinking that if you wanted functions to be overridden, you would have written them that way.  Plus sharing the code later adds a step for anyone using it... something else I'd like to avoid.

In this case, how do I proceed?  Do I just need to deal with telling folks to modify NGUI source code later so that I can extend as needed or is there something I'm missing?

Any help is appreciated!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Extending UIInput
« Reply #1 on: October 09, 2013, 09:06:32 AM »
There are two third-party packages on the Asset Store that extend UIInput's functionality, adding support for highlighting, selection, multi-line input, and more. Why not just use one of them and save yourself some time here?

Also keep in mind UIInput is going to be changing in the very near future. So if you don't want to use third party packages, just make a copy of UIInput and modify it as you see fit. That's what the other guys did.

r-dotPhunky

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 4
    • View Profile
Re: Extending UIInput
« Reply #2 on: October 09, 2013, 12:06:20 PM »
I had seen a solution out there that didn't appeal to me.  Another search today did find one that seems promising but it does not have a demo so I'm hesitant to buy.

I was also using the whole thing as a learning experience. :)

You answered my question regardless though - Worst case I can make a copy of UIInput and extend from there.

Buuut if UIInput is going to change in a major way, it probably is best to hold off either way.

Thank you a ton, I appreciate your response!