Destroy An ScriptableObject Instance in Runtime
Hi ! For spell system i've create a abstract class "Spell" with some methodes as a scriptable object. I've create other derived class for each spell. So I can manage my spell in the project widows and add to object who need, this spell data. Each time an object use a spell, it copy the derived "SpecificSpell" abstract class (as Scriptable Object like the parent script "Spell") to modify spell values (like damages).
To do that : I call this methode in my object need cast a spell : avaibleSpells[0].CreateNewSpell();
CreateANewSpell is an abstract return methode of "Spell" abstract class : public override NewSpell CreateNewSpell() { return new Spell_Darkness(this, darknessExplosion, darknessBall); }
And this is the derived Spell Script constructor ( for each spell) : public Spell_Darkness(NewSpell spell, GameObject darknessExplosion, GameObject darknessBall) { this.darknessExplosion = darknessExplosion; this.darknessBall = darknessBall; //Parent script vars spellName = "Darkness"; spellOccurence = spell.spellOccurence; spellLevel = spell.spellLevel; spellModifier = spell.spellModifier; spellDuration = spell.spellDuration; spellAttackDetails = spell.spellAttackDetails; setEffect = spell.setEffect; }
So I Create an instance of scriptable object to use it in runtime, but where go this scriptable object when spell end ? I decided to create in "Spell" abstract class a methode call when spell end : public virtual void DestroyTheSpell() { Destroy(this); }
But i'm not sure of that, is the instance go to somewhere in Unity .. ? Sorry for my english ;) And thanks a lot !
Your answer
Follow this Question
Related Questions
360° Video player made in Unity - example scene, code or plugin 1 Answer
InvokeRepeating parsing a value 0 Answers
Crouching script need help please 1 Answer
Running 'helper' programs, 0 Answers