Unity Hints Part 1

Author: Florian Graf | Published: 2019-09-28

Pixabay Hint Harishs CC0

This is the first post in a series about hints for working with Unity. Those are just smaller things I come across and find interesting or helpful to know. Since I don’t have time to write an entire blog post about every of those topics or the hint is only so small that it doesn’t deserve its own entry, I’ll collect them for this series. In each post I’ll provide a few. Here are the first of them.

Work with the editor

Really try to work with the Unity editor. This might sound strange as a hint, since you obviously have to work with the editor to create your game. But I recommend that you really focus on the editor a lot more.

There is a danger that you look at Unity more as a programming framework only and thus use the editor to configure, debug or view your game. The editor might become a secondary tool and you try to solve most things via programming. Try to approach it different and make the editor your main tool. Piece together your game in the editor. Only if you have missing pieces go ahead and develop them. Keep those pieces small and reusable. You don’t create your game by programming it but by piecing it together in the editor.

Try to have small and reusable components. Reference those components to each other in the editor. If you use any events consider using UnityEvents to manage them in the Editor. Use ScriptableObject or expand the editor itself for your needs.

Use Scriptable Object

Everyone that has worked with Unity knows the GameObject. But beginners probably don’t know the ScriptableObject. It provides functionality as an asset and is not part of the GameObject hierarchy in the scenes. They are not just data storage like mentioned in the reference manual, but have a versatile of different applications. I highly recommend to read Architect your game with Scriptable Objects to get an idea of the possibilities.

Expand the editor

The Unity editor is an Unity application itself. And you can very easily expand it with your own code. There are next to no limits in this. Do you need a tool to help develop your game, write it for your editor so you can directly integrate it. Expand your editor and improve your workflow for the game you’re developing. If you continuously use similar features across projects, you can also build a DLL and drop it in as a plugin.

Just put your scripts or the DLL in a folder called Editor anywhere in your assets and they will be loaded and executed by the editor. The unity manual has plenty of information about it. Go check it out.

Explore UI Elements

If you’re still creating UIs in IMGUI and Unity UI you should take some time to look at UI Elements. There was also an official blog post about it that is worth reading. It is a new UI system that is currently available for expanding the editor, but in the future will be available for your games as well. It is heavily influenced by HTML, CSS and JavaScript/JQuery. You write UXML, USS and add logic with C# and UQuery. You can load UXML and USS dynamically and change them at run-time. They even support hot-reloading on their own. It is most definitely the future of creating user interfaces in Unity.