Search Unity

How to make a custom version of Input Field?

Discussion in 'UGUI & TextMesh Pro' started by bzm3r, May 28, 2017.

  1. bzm3r

    bzm3r

    Joined:
    May 28, 2017
    Posts:
    1
    I am very new to Unity (but not scripting/programming), so my question is fairly basic.

    I understand that Unity UI is open source: https://bitbucket.org/Unity-Technologies/ui/

    I am interested in making a custom version of Input Field, that would function as a more comprehensive "Text Editor" component. What would be the best way for me to implement "Text Editor"? Should it be a component at the same level as InputField.cs? I am guessing not, and that instead Text Editor should inherit from Input Field? Is it possible to inherit from Input Field, rather than the usual MonoBehaviour?
     
  2. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,712
    Yes, you can derive from Input Field. I've done that once for fun to add some personal touches to it :)

    small note: If you're interested, you could get yourself a free copy of TextMeshPro , on the asset store (which will someday be integrated into Unity). It has some nice additional features that you might want to use and/or that you might have wanted to do in your custom version, etc.. (I think that you can extend that, also, but I can't remember if I've tried or not. -- and while the free version won't give you source code, but it may still be worth a look).
     
  3. pete

    pete

    Joined:
    Jul 21, 2005
    Posts:
    1,647
    i was just about to start a new thread on input field inheritance. the problem with inheriting directly is that many of the methods are protected or private. for any customization of the default behavior you really have to change the class.

    @Stephan-B is there any compelling reason not to make methods virtual and properties public/protected rather than private? i've only glanced through the repo a few times. maybe base class issues prevent it. the advantage would be we could derive from input field and override say Select or LateUpdate without having to compile our own UI DLL and altering everyone's installs. we're really fighting with those issues in one of our current projects right now because it needs to behave differently than the default. and yes, maybe i should start a new thread on that ;)