Nerd For Tech
Published in

Nerd For Tech

Scriptable Objects in Unity

Objective: Use scriptable objects to fill-out a game object template.

We’ve been tasked with creating an interactive for visitors to a zoo. When the user clicks on an area of the map, we reveal a card with animals and facts that apply to that area.

Imagine if we had 50 exhibits. Creating a page for each one would take a lot work. Luckily, we can create one template and use scriptable objects to populate it!

Our scriptable object definition is really simple: Three strings to hold the text info and a sprite to hold a picture. All of our scriptable objects will contain these fields. The very first line, starting with [CreateAssetMenu… will allow us to use Unity’s editor to create scriptable objects using this template.

There’s our Card item in the Asset Menu!

We’ll create a new Card and name it BearDen. Then we simply fill-in the fields.

Here’s our card panel template. The Title Text, Info Text, Animals Text, and Animal Image objects will be filled-in by our scriptable object.

Here is our exhibit button script. When the button is pressed, the OnPress method will be called, passing our scriptable object to the UIManager’s DisplayCard method.

Here is our Bear Den button. We can see the ExhibitButton.OnPress method is connected to it.

Here is the UIManager’s DisplayCard method. It turns off the map panel, enables the card panel, and calls the card panel’s PopulateCard method, passing-in our scriptable object.

The final piece of our solution is the card panel’s PopulateCard method. It takes-in the scriptable object, and assigns each of the fields to its child objects.

And here is our finished Bear Den card!




NFT is an Educational Media House. Our mission is to bring the invaluable knowledge and experiences of experts from all over the world to the novice. To know more about us, visit

Recommended from Medium

The Essence of Programming

Anime Metaverse Community Verses#17: Anime Metaverse — Setting NFT Project Etiquettes

Feature selection in Python using Filter method

Connecting DApp to Metamask Wallet and Using of Ethers Library

An Easy Guide to Creating WordPress Workflow Documentation

You’re a Brand, Shape It for Success

person standing with arms wide open facing the sun

Dart’s Async and Await.

I Made a Game With Unity

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
Ryan Sweigart

Ryan Sweigart

An independent Unity Developer.

More from Medium

Making a Dash Mechanic for your game

Score Implementation

Canada at Expo Dubai 2020 — Virtual Experience Case Study

Inside the monolith

Developing A Game Engine with Perl