Unity 3D – Intro about attributes and events .

This will update your component into the visual area of Unity.
Some public variables will be fashioned and change with your selected attributes.
The attributes can be used into programming using the [].
The class can have on top this attribute and is followed by the code source.
this will add a URL

this will block drag and drop your component to just once.

this will block remove the component depend on TEST.

You can remove step by step , but when you add this also add both this component and the TEST component.
Many attributes use sections used to separate and show info, like:
show word Details

make a space into Unity Inspector

show the header like Stats

this tell is multiline for the text area

renders a flexible textbox with a scrollbar.

create a slider from 0.0 to 360.0 for variable circle_angle

will hide the public variables

this will execute the code, for example, you can execute the camera follow even you don’t use play mode.

this allows running code GiveObject by creating a menu on
Tools – Give object – Do it

then when play and used it this will run GiveObject

this gets serialized even though it is private

This can be a good example when you use sprites and colliders.
Example:

Then you need to use them and need to tell Unity something about your code

… and will show on development like a warning message “This one is old”

This part of the tutorial is more complex and is about events:
This attribute tells Unity can serializable something ( like using events system).

Example with one serializable event:

I named the script, class, and variable for the event just to understand how this works.
You can use anything else for the event : read_event_player, read_heat, read
You can change the name of the script or the class for the event.
You can add Listener into your script and use them
NOTE: You can add new listeners to the event, but you cannot see them in the Unity Inspector.
Example: use Start area of code to add this:

then create this to use it:

If you take a look on Unity Inspector you don’t see this, just the print of Debug.Log
The part of This event is old but is often used by users.
You can use C# events and not Unity events.
The Unity events are super powerful for Unity development and are easy to use them.
If not you need to have some custom code for this type of tasks.
You can use something else into events (but not more 4 args) :

and use it

This is a little tricky but you can pass anything you want with events system.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.