So, I feel a bit of context is important for you guys to understand what I’m trying to do:
In my game, I have a bunch of characters which have to refer to sprites. said characters are all tied to an interface with the different methods and behaviours they are to implement; something of this sort:
public class NPCJonas : NPC
{
Sprite spr_frightened;
Sprite spr_happy;
// Interface's methods go here...
// Original methods go here...
// And so on...
}
This works really well when paired with a manager class, since then I don’t need to have game objects for each of my NPCs polluting my scene, and I can just refer to them by an arbitrary id. Organized and effective, except for one detail: those sprites there will, of course, never show up in the inspector.
Before I go any further, let me say that I already thought about scriptable objects; in fact, my very first implementation of the NPCs was done using scriptable objects, although the NPCs were much more uniform, and I didn’t have to use any inheritance; when inheritance is needed in order to provide radically different behaviour between NPCs, however, scriptable objects just didn’t seem to be adequate to handle the problem (unless I’m missing something, of course), since I’d basically have to have double the files for each NPC (one for the script itself, and one for the actual scriptable object), and that just seemed silly to me.
Now, the original idea I had, was to simply get the assets in that NPCs constructor as the game was initializing, but I just don’t know how to go about it. I’ve tried Resources.Load(), but it always gave me null, even with my resources in the resources folder.
My current solution is to have another Image Manager game object which would have all the sprites in the game contained in an array, and from which I could get a sprite specifying an id. This works perfectly, but I can’t help but wonder if it’s the best way to do things; if I was programming an engine from scratch in C, this is definitely how I’d do it, but it just doesn’t feel very “Unity-y”, you know?
Anyway, any help and opinions on my current approach would be appreciated.
Thank you in advance.