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!



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.

[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";



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!