Search Unity

Custom Text Renderer sticking around after disabled

Discussion in 'UGUI & TextMesh Pro' started by RiokuTheSlayer, Feb 17, 2016.

  1. RiokuTheSlayer

    RiokuTheSlayer

    Joined:
    Aug 22, 2013
    Posts:
    356
    Hey all!

    I have a little problem with one of my custom UI elements.

    I'm writing up a custom Text element, and the problem is that whenever it's disabled (The object or the component), the text from the custom element stays on the screen.

    From what I can guess, the Canvas Renderer is rendering before the settings are changed. Therefore, when the object is disabled, the rendered bit stays, even though it was set to not render anymore.

    I'm basically generating a mesh using this , then setting the Canvas Renderer's mesh to that new mesh I generated.

    The default components of the UI (Image, Raw Image, Text, ect) don't do this. It seems like they probably have a custom OnDisable() method that cleans up. Any insight into how this works would be awesome.
     
  2. RiokuTheSlayer

    RiokuTheSlayer

    Joined:
    Aug 22, 2013
    Posts:
    356
    And three seconds after posting this I found CanvasRenderer.Clear()

    Well. In case anyone needs it, here's the thread.