there is a list of all command like [Random(,)],[HideInInspector] etc…? I see some of those in tutorials and I will be so happy if I can find more command like this and what they do
If you want to search for more, try to use the term ‘attribute’ (that’s how they are called in C#).
There are plenty of them, you could actually find every single one by either inspecting the assemblies or writing a program that does it for you.
Haven’t seen an official list of the most common though.
Moved to getting started.
Thanks
MSDN is also a good place to look, for any attributes that are part of .NET and not Unity.
However since you can easily write your own attributes, its not possible to provide a single list with every possible attribute.
And writing your own is not only easy, but incredibly useful. Once I figured out the simple mechanics of this, it’s saved me so much grief!
do you know any tutorial about how to make an atribute?
Not off hand, but here’s a very basic one that I did (from another post somewhere) for a readonly property in the inspector. In this case I wanted it to show in the inspector (so it had to be public) but I didn’t want to be able to change it in the inspector.
ReadOnlyAttribute.cs
using UnityEngine;
public class ReadOnlyAttribute : PropertyAttribute
{
}
This is just an empty class so that we can apply it in an editor script.
Editor_DoReadOnlyDrawer.cs
using UnityEditor;
using UnityEngine;
[CustomPropertyDrawer(typeof(ReadOnlyAttribute))]
public class Editor_DoReadOnlyDrawer : PropertyDrawer
{
public override float GetPropertyHeight(SerializedProperty property,
GUIContent label)
{
return EditorGUI.GetPropertyHeight(property, label, true);
}
public override void OnGUI(Rect position,
SerializedProperty property,
GUIContent label)
{
GUI.enabled = false;
EditorGUI.PropertyField(position, property, label, true);
GUI.enabled = true;
}
}
This is the PropertyDrawer that reads the attribute tag and simply disabled the EditorGUI pushes the value, the reenables the EditorGUI.
Other.cs
[Tooltip("Patrol path has been randomly reversed.")]
[ReadOnly]
public bool reverse = false;
This is where I’ve added it in my code. This bool gets randomly assigned on Awake() for each object. But to help test and debug, I needed to be able to see this value on each object without having to throw a break point in the code. In the inspector, it looks like this:

The value is properly reflected (in this case true), but the variable is greyed out and cannot be modified.
As I said, this is a pretty simple use-case, and you can actually get pretty crazy with things.