Scriptable objects using sprite atlas?

Hi there peeps.

Background : A simple 2d game.

Subject: “Handling different themes”.

methodology:
Using ScriptableObject to store different sprites( UI images, i.e buttons images, panel image, Background Image( almost 15 sprites)). On change theme command I call the ScriptableObject and take the sprites out of the S-Object.

and using 6 ScriptableObjects for 6 different themes in my game.

----------Now------

What to do? declare 15 sprites in Scr-Object and do it like described above? or pack all the sprites in a sprite atlas and declare a function with in ScriptableObject class to get the desired sprite and set it upon receiving change theme command ?

which one is better in your opinion and why? or is there even better solution. Do let me know.

thanks.

??anyone?

Is that an assignment?

If you played a bit with Sprite interface
https://docs.unity3d.com/ScriptReference/Sprite.html
You’d notice that packing is normally done by unity.

The approach described where scriptable object serves as “data block” and stores references to used sprites is good enough. Additionally, there’s no real reason to add any methods to it. It can be just completely passive datablock.

No this is not an assignment. I am working on a 2d game.

for themes i have two options

  1. simple scriptable object with sprites
  2. simple scriptable object with sprite atlas.

both can output same thing, and I can implement both easily. Just need to know which one is better if any?

Neither is better. Since both are “simple” you can try both and see if one of them works better.

Personally, I wouldn’t bother with custom implementation of sprite atlas, unless I’m forced to do that for some reason.

So just go with solution #1, unless you hit some sort of problem.

1 Like

best mate. Thanks alot.