Click here to Skip to main content
15,860,972 members
Articles / Programming Languages / C#
Tip/Trick

How to Add Comments/Notes to a GameObject in Unity3D

Rate me:
Please Sign up or sign in to vote.
5.00/5 (2 votes)
2 Oct 2017CPOL1 min read 28.7K   1   3
This short tip teaches you how to comment a gameObject in Unity game engine for documentation purposes.

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:

  1. Create a script called "ThisIsComment". Remove everything from the script and copy the following code to it:
    C#
    using UnityEngine;
    /// <summary>
    /// Attach this script to any gameObject for which you want to put a note.
    /// </summary>
    public class ThisIsComment : MonoBehaviour
    {
        [TextArea]
        public string Notes = "Comment Here."; // Do not place your note/comment here. 
                                               // Enter your note in the Unity Editor.
    }
  2. Attach this script to all of the gameObjects to which you want to add note (you can drag this script to the gameObjects or to use "Add Component" button in the corresponding Inspector window). Here is an example:

    Image 1

    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.

  3. (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.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Engineer
Canada Canada
I develop virtual reality applications.

Comments and Discussions

 
SuggestionPretty useful! Pin
HernandoNJ2-Feb-21 18:00
HernandoNJ2-Feb-21 18:00 
GeneralMy vote of 5 Pin
HernandoNJ2-Feb-21 17:57
HernandoNJ2-Feb-21 17:57 
PraiseGood tip Pin
rvangaal9-Oct-17 0:16
rvangaal9-Oct-17 0:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.