- Home /
Simple text in inspector components?
Curious if its possible to add simple text to my components in the inspector view, rather then having a blank component with no fields it'd be cool to write up a short description of what that component consists of
When i started with Unity. I also wanted something like this.
Would have made easier to remember what each and every component I added does.
But with time, you eventually memorise Unity components. And with scripts. I usually write the description of script inside it at the top :)
Thanks for the reply :) I'm usually pretty good at remembering what my components and systems are up to, I suppose I'm just in a refactoring moment and been documenting/cleaning my code lately, making things as user friendly for myself as possible. I figured being able to write up a short description there would be a neat thing to have in the future while I'm slapping components together
http://docs.unity3d.com/ScriptReference/EditorGUI.html
might be of some help.
Answer by DiegoSLTS · Mar 22, 2015 at 07:30 PM
You can create a custom inspector class for your script and add a HelpBox on it with any text you want. Look here: https://unity3d.com/es/learn/tutorials/modules/intermediate/editor/drawdefaultinspector-function
That's what I was lookin' for, thanks!
Edit: Just in case anybody finds there way here looking for a similar solution, here's my snippet with rich text enabled.
[CustomEditor(typeof(AG.RTS.Gameplay$$anonymous$$anagers))]
public class Gameplay$$anonymous$$anagersEditor : Editor
{
private GUIStyle style;
public override void OnInspectorGUI()
{
style = new GUIStyle("HelpBox");
style.richText = true;
base.DrawDefaultInspector();
EditorGUILayout.TextArea(@"<b>Gameplay $$anonymous$$anagers</b>
-----------------------------
<color=blue>Entity$$anonymous$$anager</color> - Collection of every valid entity in-game
<color=blue>Selection$$anonymous$$anager</color> - $$anonymous$$anages selected units in a collection
<color=blue>Drawer</color> - GL draws in game-world", style);
}
}
Answer by Xatu1992 · Mar 22, 2015 at 03:25 PM
var Description : String;
This would work if the string isn't being called to anything.