Scriptable objects to make easy Templates!

I have been hard at work making this map application for an imaginary zoo. Currently I am working on the animal information cards that appear when selecting each section of the park. To make this easier and template based, let us make this into a scriptable object!

Creating a new script called “CardModel”, I have it inherit not from Monobehavior, but ScriptableObject. Below we set the template of what we would want within each card, as can be seen with the Africa card above.

The issue now is that because this does not inherit from Monobehavior, you cannot attach it to any Game Objects. Instead we can add the CreateAssetMenu line, and…

… like magic, we can now create objects that are templated to this script!

Each of these scriptable objects can be filled in the inspector and I have created one for each of the cards that I will need.

In a card view script I had created before and we put each of the scriptable objects into the array. Afterwards I create a new method in the script that will take from our variable card, which is an int, and thennnnnn associate that with an OnClick event for each map area’s button!

So for this button, it will call #5 within the array, and what we get is our Monkey Habitat information!

Scriptable objects can be used for a variety of things, items in a game are one! I better keep them in mind for the future.

See you next post!




Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Getting into a Grad School

Computer Shop Aston

Aston Computer Shop

Dependency Injection in Spring

DevOps Implementation: Best Practices Using Alibaba Cloud

Spring Data JPA Composite Key Mapping Example

Creating and using debug symbol tables with CMake and GDB

Manual Taxes With ZenBasket

A Day in Google Developer Days

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
Edward Kim

Edward Kim

More from Medium

2.5D Platformer: Creating a Physics-Based Character Controller

Unity Tutorial — Rim Light shader

Daily Progression: Main Menu Layout!

Level Design in Unity Part 2: The Walls