unity3d Attributes Component attributes

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

[DisallowMultipleComponent]
[RequireComponent( typeof( Rigidbody ) )]
public class AttributesExample : MonoBehaviour 
{
    [...]
}

[DisallowMultipleComponent]

The DisallowMultipleComponent attribute prevents users adding multiple instances of this component to one GameObject.

[RequireComponent( typeof( Rigidbody ) )]

The RequireComponent attribute allows you to specify another component (or more) as requirements for when this component is added to a GameObject. When you add this component to a GameObject, the required components will be automatically added (if not already present) and those components cannot be removed until the one that requires them is removed.



Got any unity3d Question?