In Unity, when using C#, once you start creating your own classes and want them to show in the inspector you need to use an attribute. That was how I started to understand what an attribute was. Attributes change metadata. This data is how the code is compiled and used - this allows you to change how the engine perceives your code.
For more info on attributes
An attribute is a declarative tag, they are written with square brackets. [System.Serializable] is, for example, what you would place above the class you wish to show in the inspector.
[System.Serializable]
public class keeper
{
public string notes = "Notes...Copy, Paste, whatever ;)";
}
This would show as a small foldout within the class in the inspector.
System.Serializable tells Unity this is like a class with a subclass.
for more information on Serializable
Unity contains many unity specific types.
CallbackOrderAttritube
Can be used for post-processing a scene with special effects, watermarks, have every new scene begin with certain objects, etc.
CanEditMultipleObjects
This attribute should be easy to figure out. You can use this to change script variables on different game objects at once or use it to change some other values on a different component.
CustomEditor
This allows you to change the inspector for select objects or use.
Unity has many more and I may go into detail about them in a later post.
CustomPreviewAttribute
CustomPropertyDrawer
DrawGizmo
InitializeOnLoadAttribute
InitializeOnLoadMethodAttribute
etc...
Here is a nice article covering the entire 65+ attributes.
For more info on attributes
An attribute is a declarative tag, they are written with square brackets. [System.Serializable] is, for example, what you would place above the class you wish to show in the inspector.
[System.Serializable]
public class keeper
{
public string notes = "Notes...Copy, Paste, whatever ;)";
}
This would show as a small foldout within the class in the inspector.
System.Serializable tells Unity this is like a class with a subclass.
for more information on Serializable
Unity contains many unity specific types.
CallbackOrderAttritube
Can be used for post-processing a scene with special effects, watermarks, have every new scene begin with certain objects, etc.
CanEditMultipleObjects
This attribute should be easy to figure out. You can use this to change script variables on different game objects at once or use it to change some other values on a different component.
CustomEditor
This allows you to change the inspector for select objects or use.
Unity has many more and I may go into detail about them in a later post.
CustomPreviewAttribute
CustomPropertyDrawer
DrawGizmo
InitializeOnLoadAttribute
InitializeOnLoadMethodAttribute
etc...
Here is a nice article covering the entire 65+ attributes.