- You can check whether a Unity.Object (including Component, GameObject, MonoBehaviour, etc.) is null using
if (variableName), because it has an implicit bool operator that checks != null.
- If you’re trying to expose generic-typed properties in the inspector, you should constrain them with
where T : Component or similar, or strange things may happen when you check whether they’re assigned.
- I probably shouldn’t rely on generics so much. It’ll haunt me if I ever need to build for mobile or console.
Continue reading The Wrong Null!
For there are many, many things that can go wrong as you try to manipulate uGUI objects. Continue reading RectTransform Gotchas
Object pooling is pretty simple, and I was put off a lot of existing guides and examples by what seemed like unnecessary complexity. Since then my own solution has probably got at least as complicated, but I’ll explain as I go; your mileage my vary. Continue reading Unity Object Pooling
Some more Unity 3D tips that I need to write down while I remember them. (You might be interested in the previous ones.)
TL;DR: Don’t forget to use Time.deltaTime for per-second change. Content Size Fitters update late, so read their properties at end of frame. Continue reading Unity Troubleshooting II
Between mentoring game jams and working on my own stuff, I’ve ended up with a list of basic Unity scripting pitfalls, many of which don’t cause runtime exceptions or log any errors. I emphasise that most of these are really basic, and anyone who spends a while with the platform will internalise them sooner or later, but if they’re not yet obvious to you, I hope you find the list useful.
Continue reading Beginner Unity Script Troubleshooting