Is there an example for using CanvasRenderer?

Is there any sample code for using CanvasRenderer? The documentation is not clear on how to properly setup the vertex array and I’m having trouble figuring this out.
Thank you.

Image and Text both use it. you can check out the source code (https://bitbucket.org/Unity-Technologies/ui/overview) and take a look

Thanks. I searched through that code and found MaskableGraphic which uses CanvasRenderer. MaskableGraphic appears to be exactly what I was looking for – a way to create arbitrary 2d shapes on a Canvas and have them get masked by a mask in a parent ScrollRect.

I was able to figure out how to use MaskableGraphic when I found the example here: Unity - Scripting API: Graphic

I really hope the documentation for all these classes improves soon as it seems like there is a lot of functionality in them that I still don’t understand. Unfortunately, most of the functionality in the UI classes seems to be implemented in code that is not part of the open-source code linked to above. More documentation with copious examples would be greatly appreciated.
Thanks.

Nope 98% of the UI code is open source. The only thing that is not is the physical drawing of the Canvas and the CanvasRenderer as they are part of the c++ code and can’t be easily separated.

That’s fine, I’m glad it’s in c++. I’m asking for more documentation because regardless of the percentages, it’s not obvious how to use these classes.

Yea i was just replying to your comment of “Unfortunately, most of the functionality in the UI classes seems to be implemented in code that is not part of the open-source code linked to above” which was technically an incorrect statement. But i do agree we need to improve the docs and we are :slight_smile:

1 Like