Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Custom Widgets!

Discussion in 'UGUI & TextMesh Pro' started by bluescrn, Aug 20, 2014.

  1. bluescrn


    Feb 25, 2013
    With little info about the new UI system, I was a little concerned that we wouldn't be able to create custom widget types (actually add our own vertices to the new UI system). But it looks like we can, and it's as simple as adding a CanvasRenderer to your GameObject, and calling SetVertices on it, with an array/list of UIVertex. Nice!

    It doesn't take indices, so it looks like it renders everything as a list of quads, which is just fine in most cases.

    Seems nicer to use (and hopefully a bit faster) than the API for creating meshes at runtime - SetVertices accepts an IList or range from an array - looks like SetVertices(array, size) - so you can avoid the constant re-allocation of arrays when increasing/reducing the vertex count.

    So adding support for unusual widgets, or something like a replacement text system, should be fairly straightforward!
    Tim-C likes this.
  2. User340


    Feb 28, 2007
    I don't even see why you'd have to bother with vertices. I can think of so many potential controls with just overriding Selectable and implementing the events.