- Home /
Card Game, cards as ScriptableObject, card effects as ScriptableObjects, effects have different parameters. How to make an inspector UI support this structure?
As the title says, I'm developing a card game in which I want the cards to be modelled as ScriptableObjects, and their "card is played" effects as ScriptableObjects too. The problem is that those Effects are polymorphic and each one has it's own parameters.
I would want the card effects to be displayed in the inspector as either [1] or [2], so that I can dinamically add effects to the list and also configure the effect parameters.
The closest I've come is by creating each effect asset with the parameters set, but I want the parameters to be configurable on the card and not on the effects (imagine having to have an effect asset for 1 damage, 2 damage, 3 damage... and so on)
https://image.prntscr.com/image/14mrXRjBS4iiMFhqqIgtiw.png
I'm assuming that either I have approached this problem in the wrong way or that I have made a mistake (or many). What should I change and implement to either accomplish [Inspector 1] or [Inspector 2]?
/u/JimWest on reddit pointed out a solution on the problem readily available to download: https://heavens-vault-game.tumblr.com/post/162127808290/inline-scriptableobject-editing-in-unity Just tested it and works like a charm.
On the other hand, after trying the solution, I found that my approach on this problem was wrong, I can modify the ScriptableObject Effect in the inspector, but multiple instances of a Card Asset sharing an Effect Asset can't have different values on the effect's variables. So I can't just have a DamageEffect instance, because changing the values from one card changes the values on every card.
In my case I've changed the approach to the problem so the parent Effect is an Interface now, and I'm currently working on having it to show on the inspector.
Answer by lukegothic · Feb 10, 2018 at 08:25 AM
/u/JimWest on reddit pointed out a solution on the problem readily available to download: https://heavens-vault-game.tumblr.com/post/162127808290/inline-scriptableobject-editing-in-unity Just tested it and works like a charm.
Answer by FDT · Feb 09, 2018 at 03:55 PM
I dont know if this is suited for your example, but I resolved a similar situation by doing this: I have a singleton manager in the scene, with scriptableobjects items added to a list on this manager.
In a x class inspector, no matter where it was used (scriptableobject in project, gameobject in scene, etc) i have some class variables (let's say ItemData) with a property drawer, that it have to be used to input a string that is an ID from the same scriptableobject items added to the singleton. I resolved it by detecting the selected scene object, and if it is the singleton, the drawer for the ItemData shows a dropdown list with the names of the items added to the singleton, and if not the case, it shows the inputfield to enter it by hand. I take care also of not doing this writtable in runtime, detect when the focus changes in the selected gameobject and some other edge situations. I hope this gaves you an idea of what to do.
Your answer
Follow this Question
Related Questions
How to access derived class members from base class type 1 Answer
How to make a deep copy of a list of ScriptableObject derived types? 1 Answer
Polymorphism with generic ScriptableObjects? 1 Answer
Polymorphic Scriptable Object 2 Answers
How to Keep Track of ScriptableObject Coroutine Durations? 1 Answer