- Home /
Easy text in the inspector
Hi guys is there a way to just write an easy text in the inspector? because I have a bunch of variables (in c#) an I want to give them a sort of title:
public Texture Darkness;
public GUISkin Skin;
public Texture Background;
public float IntroDauer = 2.0f;
private float adopePositionTime = 0.1f;
public float AbstandY = 10;
public float GroesseX = 100;
public float GroesseY = 40;
public Texture topPart;
public float GroesseHeader;
public bool anBildschirmAusrichten = true;
And is there a way to add a text as easy as: static text = "----Intro----";
Or something like this?
btw, it' funny you mix english and german names ;) You should stick to one language it just gets confusing that way. Usually the best choice is english variable, class and function names. German has some nasty special characters ;)
Also keep in $$anonymous$$d there are vector types (Vector2, Vector3, "Vector4">http://unity3d.com/support/documentation/ScriptReference/Vector4.html>"Vector4) which combine x and y into one variable (of course Vector3 has additionally z and Vector4 z and w).
yes I realized it afterwards also ;D sorry for that
Answer by Bunny83 · Jun 24, 2012 at 11:56 AM
To me that sound like you want a custom inspector for your class. If you don't write your own inspector for your class, Unity uses the default inspector which just displays all serialized values by it's variablenames.
Usually variable names should be self-explanatory, so there's usually no need for writing your own inspector. But if you want to change the description of your variables or change what editor element is shown to edit a certain value, you can write a custom editor.
See the bottom of the Extending the editor page and the Editor class.
A custom inspector can provide a nice interface for your class. You can show a slider with certain min and max values for a float instead of an float field where the user can input any value.
If someone have a similar problem, try using HeaderAttribute
[Header("Your title")]
using UnityEngine;
using System.Collections;
public class ExampleClass : $$anonymous$$onoBehaviour {
[Header("Health Settings")]
public int health = 0;
public int maxHealth = 100;
[Header("Shield Settings")]
public int shield = 0;
public int maxShield = 0;
}
Wich result in
Just want to add that the HeaderAttribute was added recently ^^. This question is four years old.
Thanks, yes I know, but in the case someone find this question randomly (as I did looking for something else), i gave an answer ^^
Answer by usergame · Mar 28, 2017 at 04:34 PM
For anyone stumbling upon this question more recently, I wrote a simple PropertyDrawer and PropertyAttribute that you can use to display notes using the built in EditorGUI.HelpBox. It's a great compliment to the HeaderAttribute mentioned in the comments by @Odyssee and lets you give a little more info. See this forum post for more details:
Hope this helps someone out.
Your answer
Follow this Question
Related Questions
Simple headline / title for a Script in the Inspector 3 Answers
Unity GUI text displaying as noise 1 Answer
Unity 4.1.2 Dynamic text disappears 0 Answers