Introduction
For documenting your Unity project, you may want to add a note (e.g., this gameObject
manages the gun inventory, etc.) to your gameObject
in Unity Editor, but currently there is no way to do so. In this short article, we show you a simple and flexible tip to add a note to any gameObject
in Editor.
Explanation
In order to add a note to a gameObject
in Hierarchies window:
- Create a script called "
ThisIsComment
". Remove everything from the script and copy the following code to it:
using UnityEngine;
public class ThisIsComment : MonoBehaviour
{
[TextArea]
public string Notes = "Comment Here.";
}
- Attach this script to all of the
gameObject
s to which you want to add note (you can drag this script to the gameObject
s or to use "Add Component" button in the corresponding Inspector window). Here is an example:
Note: Do not change the content of the script. To add your note, go to the Unity Editor and write your note there (not in the script!).
Obviously, each gameObject
can have a different note with this method.
- (Optional): To make your note stand out from the other components in the Inspector window, move the "
ThisIsComment
" script up. To do so, click on the script
name and drag it below the Transform
component.
Note: After moving the component up, Unity might warn you that "This action will lose the prefab connection. Are you sure you want to continue?". Don't worry. Select "Continue" and then click on the "Apply" button on the top-right of the Inspector in order to apply this change to its prefab.