ScriptableObject combination table.
I'm currently using ScriptableObjects to represent Elements. Things such as 'Fire', 'Water', 'Earth', etc. These ScriptableObjects have other information in them (such as a description of each, a sprite to use as an icon, etc)
Ideally, I'd like to have a table-type-thing that would be used to 'look up' how these elements may combine. For example, I'd like to make Fire+Earth = Metal (and similarly, Earth+Fire = Metal). If possible, I'd like to make this visible in the inspector to allow easier designer manipulation.
That being said, I'm not sure how to do this. I considered using the Element's ID as an index number in a static 2-dimensional array, but that seems sloppy, requires repeated efforts (earth/fire, fire/earth), and error prone. I also considered a static function that accepts two elements and returns the new element, but I'd rather not hard-code that kind of stuff and I still need a direct reference to the ScriptableObject to return, which seems sloppy.
I'm looking for any insight into a way to achieve what I want, or even a better approach. I'd like to continue using SO's for the Elements if possible, but I'll definitely listen to any advice otherwise.
Thanks!
Answer by misher · Dec 04, 2018 at 07:22 AM
Here is what I can suggest you. Create an enum for element type with flags attribute, similar like there are unity layers for example, so you can select multiple values, then when you combine two elements you just use bitwise operators to add elemt types of both and you set your enum in such a way that combined type results in the new element type. This system may be not very flexible though, but it worth trying ig
Your answer
Follow this Question
Related Questions
Access an Array of class inside another Array of class? (EditorGUILayout) 1 Answer
Assign ScriptableObject (Inventory DataBase) 0 Answers
Serialize a list of class containing ScriptableObject assets 0 Answers
Static function not working in between screen 2 Answers
[SOLVED] ScriptableObject generic list makes all derived instances to base type when serializing 1 Answer