Unity — changing material with enums

Let’s take our previous example a step further… Suppose we want to change the color of our ai to match the change in speed when we press the space bar, like this:

Since we’ve already set up our custom class, we can easily add a material to our enum:

Now we can add our materials using the inspector:

And with a few extra lines added to our Speed script:

We’ve done it!

--

--

Unity and Flutter developer interested in creating mixed-reality applications.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Richard Morgan

Unity and Flutter developer interested in creating mixed-reality applications.