Skip to main content
deleted 1 character in body; edited title
Source Link
Vaillancourt
  • 16.4k
  • 17
  • 55
  • 61

Can I resethreset the `[DisallowMultipleComponent]` attribute in child classes in Unity somehow?

Can I resethreset the [DisallowMultipleComponent] attribute in child classes in Unity somehow?

I want to create my base class:

[DisallowMultipleComponent]
public class MyCompanyClass : Monobehaviour {}

I want all my component scripts to inherit from the MyCompanyClass. So, I will be able to add only one instance of my component script to a game object at a time. I need it for most of my classes. But for some classes I still want to preserve the ability to add a few class instances to a game object, while still inheriting from the MyCompanyClass (because I am going to put some custom behavior into it, which is going to be used by all my component scripts).

So, I was trying to search for something like [AllowMultipleComponent], but found nothing. Is there maybe another way to achieve what I want?

Can I reseth the `[DisallowMultipleComponent]` attribute in child classes in Unity somehow?

Can I reseth the [DisallowMultipleComponent] attribute in child classes in Unity somehow?

I want to create my base class:

[DisallowMultipleComponent]
public class MyCompanyClass : Monobehaviour {}

I want all my component scripts to inherit from the MyCompanyClass. So, I will be able to add only one instance of my component script to a game object at a time. I need it for most of my classes. But for some classes I still want to preserve the ability to add a few class instances to a game object, while still inheriting from the MyCompanyClass (because I am going to put some custom behavior into it, which is going to be used by all my component scripts).

So, I was trying to search for something like [AllowMultipleComponent], but found nothing. Is there maybe another way to achieve what I want?

Can I reset the `[DisallowMultipleComponent]` attribute in child classes in Unity somehow?

Can I reset the [DisallowMultipleComponent] attribute in child classes in Unity somehow?

I want to create my base class:

[DisallowMultipleComponent]
public class MyCompanyClass : Monobehaviour {}

I want all my component scripts to inherit from the MyCompanyClass. So, I will be able to add only one instance of my component script to a game object at a time. I need it for most of my classes. But for some classes I still want to preserve the ability to add a few class instances to a game object, while still inheriting from the MyCompanyClass (because I am going to put some custom behavior into it, which is going to be used by all my component scripts).

So, I was trying to search for something like [AllowMultipleComponent], but found nothing. Is there maybe another way to achieve what I want?

edited tags
Link
Vaillancourt
  • 16.4k
  • 17
  • 55
  • 61
Source Link
some1 here
  • 435
  • 4
  • 8
  • 24

Can I reseth the `[DisallowMultipleComponent]` attribute in child classes in Unity somehow?

Can I reseth the [DisallowMultipleComponent] attribute in child classes in Unity somehow?

I want to create my base class:

[DisallowMultipleComponent]
public class MyCompanyClass : Monobehaviour {}

I want all my component scripts to inherit from the MyCompanyClass. So, I will be able to add only one instance of my component script to a game object at a time. I need it for most of my classes. But for some classes I still want to preserve the ability to add a few class instances to a game object, while still inheriting from the MyCompanyClass (because I am going to put some custom behavior into it, which is going to be used by all my component scripts).

So, I was trying to search for something like [AllowMultipleComponent], but found nothing. Is there maybe another way to achieve what I want?