Scriptable Objects, magical bytes of data.
Scriptable Objects are these bite-sized objects that you can create via your in-game editor. If you have something you want to have spawning a particular way, you can do that with Scriptable Objects. They can also hold details for cards and eventually you can build custom editors for your scriptable objects… but that’s far into the future.
Get cameron mcleod’s stories in your inbox
Join Medium for free to get updates from this writer.
To create the code file for your scriptable object, right click on your scripts folder -> Create -> Scripting -> ScriptableObject Script
This script is built on less code and more data. However you can use it to make several things easier for your code.
using UnityEngine;
[CreateAssetMenu(fileName = "EnemySpawnConfiguration", menuName = "Scriptable Objects/EnemySpawnConfiguration")]
public class EnemySpawnConfiguration : ScriptableObject
{
public Enemy enemyPrefab;
public Vector2[] spawnOffsets;
public int spawnCount
{
get { return spawnOffsets.Length; }
}
public int spawnerID;
public float delay;
public PostWaveFlag flag = 0;
}
public enum PostWaveFlag
{
None = 0,
UntilAllClear,
BossWave
}This is the entire code for the EnemySpawnConfiguration scriptable object. This allows enemies to spawn from specific spawners I’ve already placed on the scene.
The other part of my hiatus over the past week, is that I’ve had a number of personal events come up. (Nothing bad, promise).
Happy coding!









