There's more...

Besides creating pluggable configurations, the ScriptableObject class helps us save memory space. Let's imagine we have a game object with several member variables with native types (for example, int, float, or string) that allocate 5 MB. To illustrate the example, let's say it's a two-dimensional array for storing a big map, among other things, and we need each enemy in the scene to have access to a copy of such a map.

If we have, let's say, 10 agents, we will be allocating 50 MB that stands for the same dataset; however, if we use a reference to an instance of a ScriptableObject file, we would be allocating the first 5 MB for the map, and a little more for the agents that hold a reference to the very same object.

Get Unity 2018 Artificial Intelligence Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.