I have a few ScriptableObjects in my Assets folder that are kind of extensions to existing AnimationClips (because I couldn't find a better way to add this data to the actual clips). they look like this:
[Serializable]
[CreateAssetMenu(menuName = "Everterra/Animation Hitboxes")]
public class AnimationHitboxes : ScriptableObject
{
public List<AnimationHitbox> Hitboxes = new();
public float StopAtNormalizedTime;
public AnimationClip Animation; // This is the "link" with the animation clip
}
now in an ECS system I want to be able to pick the respective ScriptableObject for the current animation that the character is playing, what would be a good way to do this?
I thought about doing a bit of codegen, similar to what the new Input System does. I would generate a static class with a map of AnimationHash -> ScriptableObject, maybe something like this:
public static class AnimationHitboxMap {
private static AnimationHitboxes _anim1 = new AnimationHitboxes() { ... }
public static AnimationHitboxes ByHash(uint hash) {
switch (hash) {
case 111: return _anim1;
case ...: return ...;
}
}
}
but it looks kinda weird and I am not sure I can read this static class from within a system?
I thought about another solution that looks "more ECS", but I am not sure how it would actually look like in practice:
- use a baking system (is this a valid use case for them?) to find all these
ScriptableObjects - create a singleton entity that holds a
BlobAssetReferencefor a big array containing all hitbox data, and aNativeHashMapto allow me to get the hitbox data for a specific aniamtion without iterating through all items - access this singleton in the system that I need the hitbox data
is it correct to use a baking system to create this singleton? 
