unity – Creating walls for a racing game?

I ended up creating my own editor tool/window combo:

enter image description here

The general idea is the following:

Click a quad vertex, add a wall point, upper point is just Vector3.up.

And allow to remove any point as well.

Along necessary data/logic, etc.

Though manually paint, any vertex can form a collider thus I’ll get vertex perfect colliders.


Here’s some tips for those who wish creating a similar tool.

Think simple, when you think you are, actually you aren’t yet; think harder!

At first I used to serialize all that data but that ended up being cumbersome.

In my case, I realized there were things to leverage:

  • the hierarchy
  • a custom editor tool

What you see below is the following:

The walls are game objects, behaviour stores references to lower points it is made of, there is a mesh filter that gets updated + a special shader; instead of using slow handles. But most importantly, you can select it, that turns out to be extremely useful in the workflow. Again, leveraging Unity integrated hit-testing in this case, no hands.

The mini-window is in the scene view, not an external one because otherwise it becomes tricky to manage. Here it’s simple, the tool is active, the window is too, period.

Then comes the good ol’ view-model ScriptableSingleton, I use it to store the tool data, for the walls as you might have guessed, they’re in another scene so no need to bother at all, it’s saved and this scene will not be in the build.

Also I needed a way to regroup colliders in scene instead of painfully navigating in a large hierarchy, for this, use the big guns with TreeView, it’s mature enough, forget about everything else such as internal ReorderableList. Don’t bother trying to make a clean tree view class, in my case it’s minimalistic and private sealed.

To keep it in sync, use selection and hierarchy change callbacks to gather components in scene, additionally sorted like they are in hierarchy using another answer I’ve posted here.

Also ObjectChangeEventStream turns out to be a good replacement for INotifyPropertyChanged, by carefully listening to the events, my mini-list stays in sync with any user action in hierarchy, undo, etc.

Most importantly, don’t give up, it took me half a dozen different designs (because there are really many more ways than you think to achieve things in Unity) and on day 3 I finally found the good one for the best workflow.

enter image description here