C
C#2y ago
Pacrombie

❔ Abstract forced empty constructor inheritance

As shown in the pictures, do I really have to have these empty constructors in my child class if I want the functionality of the abstract class's constructors? If I remove them from the child, I get an error: CS1729: 'PlayerAbility' does not contain a constructor that takes 0 arguments
22 Replies
Aaron
Aaron2y ago
yes, you do
Pacrombie
PacrombieOP2y ago
:(
Aaron
Aaron2y ago
...why do you have a destructor
Pacrombie
PacrombieOP2y ago
Does this indicate I've bunged up my design, or is this typical?
Aaron
Aaron2y ago
I mean, it's fine
Pacrombie
PacrombieOP2y ago
Aaron
Aaron2y ago
that's cursed don't do that
Pacrombie
PacrombieOP2y ago
If I don't stop the Coroutines I'm gonna get some nullreferenceexceptions Should I just stop them in the method that removes the ability?
Aaron
Aaron2y ago
do those coroutines reference this class
Pacrombie
PacrombieOP2y ago
yes
Aaron
Aaron2y ago
do they keep an instance of this class then this destructor will never be run while those coroutines exist destructors are run when the GC collects an object
Pacrombie
PacrombieOP2y ago
Aaron
Aaron2y ago
which cannot happen while it is referenced somewhere
Pacrombie
PacrombieOP2y ago
ah
Aaron
Aaron2y ago
sorry, finalizers
Pacrombie
PacrombieOP2y ago
Aaron
Aaron2y ago
C++ calls them destructors yeah, that's an instance method the destructor won't run until that coroutine is done
Pacrombie
PacrombieOP2y ago
i have the coroutine on the ability object, but it is being run on the player since the ability is not a monobehavior (unity) so im good to just delete the constructor?
Aaron
Aaron2y ago
delete the finalizer, yes if you're using a finalizer outside of like, native file handles, you're probably doing something wrong
Pacrombie
PacrombieOP2y ago
i might run into some weirdo stuff with ui trying to update the cooldown of an ability after its been taken off but ill deal with that when i get to it thank you for your help
Anton
Anton2y ago
unity cleans them up when the object gets destroyed, at least it should in pronciple
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server