How can I have custom inspector variables in an object list?
How can I have custom inspector variables in an object list?
To explain my problem, I have created an image with my favorite framework .... paint. (The result I want to have is in red).
As you can see, I have a ScriptableObject to create spells and I want to add several effects on them.
But these different effects don't need the same variables.
If you have an idea to implement this system or just keywords to help me, you are welcome :)
using System;
using UnityEngine;
public enum SpellEffectEnum {
TELEPORT,
PUSH,
DAMAGE
}
[Serializable]
public class SpellEffect {
public SpellEffectEnum effect;
public bool applyOnOwner;
public bool applyOnMate;
public bool applyOnEnemy;
public void Apply(Entity launcher, Spell spell, Vector2Int targetPos) {
if(effect == SpellEffectEnum.TELEPORT) SpellEffectTeleport.Apply(launcher, spell, this, targetPos);
else if (effect == SpellEffectEnum.PUSH) SpellEffectPush.Apply(launcher, spell, this, targetPos, nbOfTile);
else if (effect == SpellEffectEnum.DAMAGE) SpellEffectDamage.Apply(launcher, spell, this, targetPos, damageMin, damageMax);
}
}
Your answer
Follow this Question
Related Questions
Loading Assets from a list 0 Answers
Unity List of Color array not showing in inspector? 3 Answers
Scriptable Object issues when inside .dll 1 Answer
ScriptableObjects corrupted? Reaching "uneditable/unreferenceable" state in Inspector 1 Answer
How do I callback when the inspector is out of focus? 0 Answers