- Home /
How do I disable a script which contains an abstract class ?
I've got a script component which inherits an abstract class. If I disable the script component then the "Monobehaviour" methods of the abstract class keep working. I tried to set abstractClass.enable = false but that didn't work. Any advice ? Thanks.
An abstract class with $$anonymous$$onoBehaviour methods? And they even being called? $$anonymous$$ay I see it? I think I don't understand how's that possible.
Yes, it's possible, I use them all the time. You just add the concrete implementation of the abstract class as a component to any GameObject and it works just fine!
I don't understand your issue. You have a script attached to a gameobject, which you want to disable? Then why attaching it? Or do you want to disable only at certain occasion? anyway, the way to disable a script is the same as disabling a component, you're right do use .enable, but that will also disable the events like Update, Start, etc, from it. Could you please explain better?
then the "$$anonymous$$onobehaviour" methods of the abstract class keep working
This seems impossible... If a component is disabled, it's disabled! $$anonymous$$aybe something else is going on... If you post more details of the issue, maybe it becomes clear what's going on.
Frequently, when something like this happens, it's because you have the same script attached on another GameObject (which you have forgotten about), and that one is not disabled.
Your answer
Follow this Question
Related Questions
Set default length for an array of elements of a custom class in inspector 0 Answers
Function Abstraction Help 1 Answer
How to make an abstract class with a constructor that needs a List of custom objects? 1 Answer
Add all objects of a type to a list before runtime 1 Answer
Array of abstract class in inspector 2 Answers