Simple Log in the inspector (Unity)

Working with my game, I came across a small “problem”, or not really a problem, but the idéa/solution may be useful to some!

Using

Debug.Log("Message");

is easily accessible for showing a messages in the console, but it can also get messy when many scripts shows different messages, and the console fills up.
The solution may be using the TextArea attribute!

In the Unity inspector, you can use use the TextArea attribute to show a few rows of text instead of only using a string.
Example:

[TextArea(20, 20)]
public string log = "";

This attribute is usefull not only when writing a descriptions to gameobjects, but also as a simple log to show what happens in the script. For example; I use this in my inventory system to log what items that was added, removed and so on.

log += "Item X was added!\n";

The

\n

at the end adds a new row to the string.

There’s probably other ways of doing this, but this worked really well for me because it’s so simple!