DEV Community

Discussion on: Making Unity games in pure C#

Collapse
 
eriksk profile image
Erik Skoglund

I went from 6 years of XNA to Unity and I saw a lot of this in my own stuff as well.
Pretty much going against the philosophy of Unity and doing more things in code than in the editor.
As the years went by I started doing more and more in the editor and while scripting UI definitely has its' place, I think that embracing the Unity editor can be really powerful.

Today I tend to do most things in editor and write scripts in a more generic way to work with UI.

Make a script to fit a container to parent, check, now I can use that for a lot of different things. Add some margin & padding and we're good to go.

But I think the biggest benefit of using the editor for this kind of stuff is how fast it actually is to build the UIs. Mainly I now use scripting for wiring things up and some smaller generic scripts to make it nicer to work with.

One of the things that really helped was making a themeable component that you can drop a theme created by a ScriptableObject to each UI game object.

Changing colors, fonts and those kind of things is extremely tedious from the get go in unity. I actually also used the hierarchy to swap primary/secondary colors when objects are nested so if you have text under a background object for example, the colors will always be right.

But I guess it's a trade-off generally speaking. And definitely a matter of taste. No way is wrong, so if this fits your way of developing then go for it!

Also now that we have nested prefabs, UI becomes a looot easier :D

Collapse
 
onmyway133 profile image
Khoa Pham

You 've just convinced me to use editor again ❤️