• VOiD1 Gaming

Scriptable Objects vs Monobehaviour: A Quick Overlook

Let’s have a quick look over the difference between the use case of Scriptable Objects and the Monobejaviour, also, further, check out the advantages and disadvantages of using it.

There’s always confusion between the use case of Monobehaviour and Scriptable Objects for the beginners to chose for their game. Also, just not choosing the right one but using it with the correct set of rules is utmost required for a good Game Design. So today, we will have a quick look over the advantages, disadvantages and the use case of Scriptable Objects and Mono-behaviour.


What is a Scriptable Object?

As Unity works with the concept of Objects, it uses MonoBehavior (Game Objects) and Scriptable Objects to perform various tasks. Being a game Engine, it’s heavily dependent on logic for the games to follow and data to adhere to the logic. With that being said, Unity made a Serializable Class, known as Scriptable Objects, which is basically a data container to store a large volume of data that can be potentially shared and used independently of script instances. This defines clearly that the main use case of the Scriptable Object is to store data and use it across your game. This is, however, different from the use case of Monobehavior where we tend to write the logic for the games to work.

Scriptable Objects vs Monobehaviour: The Difference?

The serialization process for Monobehaviour is handled by Unity automatically. To work with Monobehaviour we need to first instantiate it. The instance present in the game will allow for further communication and the logic to execute. This means for every individual object you need to have an instance of Monobehavior storing all the data. This would increase memory consumption and is not at all a good way of building games.


Whereas, Scriptable Objects are made in a way to reduce memory consumption and make it easy to debug while adapting a clean Game Design Architect. Unlike Monobehavior these are standalone objects that don’t require any instance to work in a game. Scriptable Objects are independent objects that can be used and communicate anytime anywhere in the game.


Hence, Monobehaviour should more be used for writing the logic of the games and Scriptacble Objects should be used to store custom data of individual objects and use them without creating an instance in the game view. We can have a reference to the Scriptable Object in the Monobehaviour and change it during the runtime. This allows every Game objects to communicate with the required Scriptable object and share data between all seamlessly. So, now as we are clear on the use case of both things, let’s head over to know a Lil more about the advantages and disadvantages of using Scriptable Objects.

Pros and Cons of using Scriptable Objects

Everything has its own set of Pros and Cons, so let’s check what are the major advantages and disadvantages of using Scriptable Objects in our Games.


Advantages

1. Easy to Debug

2. Clean Game Design Architect

3. Low Memory Consumption

4. Editor-friendly

5. Can be Serialized by reference

6. No instance required

7. Can be saved as Assets

8. Can be saved during runtime

9. Good for prototyping

10. Modular Design Approach

11. Independent Data container

12. Highly customizable Game Balance


Disadvantages

1. Don’t allow to edit outside Unity

2. Not highly scalable as JSON.

3. Values don’t reset after the runtime in the Editor

4. Values don’t save on a standalone build


So, these were some of the greatest advantages and a few setbacks of using Scriptable Objects while developing games. For more information on Scriptable objects check the resources given below –

  1. How to Architect Game Code Scriptable Objects

  2. Create Scriptable Objects with Unity


Start Game Development Free of Cost

Get 100% Free Assets for your Games.
Get Started with your First Platformer Game.

Also, check for more informative resources to boost up your Game Development journey –

  1. Unity Random Function - A Brief Guide

  2. 10 Basic Principle of Game Design

  3. Flow Theory in Game Design

  4. Importance of Typography for Games

  5. Importance of UX in Games

  6. Making Accessible Game Design for Disabilities

With Love From VOiD1 Gaming


Recent Posts

See All