Advertisement

Question about default UI button in Unity (latest version)

Started by September 25, 2017 04:46 PM
2 comments, last by jkuehlin 7 years, 5 months ago

Hello. 

I'm creating text objects on a 2D Canvas in Unity. It is possible to tell the engine to default the text color white, the font to size 20, or the alignment to center (for example)? 

Thanks :D

This is my placeholder signature

I'm not sure if the actual defaults can be changed, but you have several options for making your own defaults:

  • You can set one text object up the way you want it, then duplicate it for all your other text.
  • You can make a prefab out of it if you intend to programmatically instantiate it.
  • You can create your own special MenuItems that set up new text objects the way you want, and use that instead of Unity's own GameObject/UI/Text menu item.  To do this, make a public static function in an Editor script (a script that's in a folder with the name 'Editor' as part of its path), and put a [MenuItem("GameObject/UI/Your Custom Text")] attribute on the function.
Advertisement

Cool! Thanks :D

This is my placeholder signature

This topic is closed to new replies.

Advertisement