Additional info in inspector?

What’s the easiest way to display information other than variables in the inspector? I’d like to be able to see the notes I make in my scripts in the inspector. Google returned way too many unrelated results. Or I just don’t know the proper term to search for.

Thanks!

you need to create a custom Inspector http://docs.unity3d.com/Documentation/Components/gui-ExtendingEditor.html (scroll a bit down to “Custom Inspectors”)

Im not so good with filtering strings but here you have a example to draw the text from the script in the inspector.

using UnityEngine;
using UnityEditor;
using System.Collections;
[CanEditMultipleObjects]
[CustomEditor(typeof(UIControls))]
public class UIControlsInspector : Editor
{
	UIControls tartegetUIControls;
	public override void OnInspectorGUI ()
	{
		DrawDefaultInspector ();
		tartegetUIControls = target as UIControls;
		MonoScript myMonoScript = MonoScript.FromMonoBehaviour (tartegetUIControls);
		string codeText = myMonoScript.text;
		GUILayout.Label(codeText,GUIStyle.none);
	}
}

That should get you started.

Explanation:

The Script have the be in a folder called Editor (just create one)
UIControls was my example script for that i changed the inspector.
UIControlsInspector was the name of the editor script.

Good look , maybe you can share your results with us.

Greetings Malzbier

EDIT: Maybe you like to use EditorGUILayout.TextArea(codeText); instad of GUILayout.Label(codeText,GUIStyle.none);

As the others said, you will need to create a custom inspector. However I would go for SerializedProperty and SerializedObject and such as this will enable “real” multi object editing plus you will get mouseover info when your cursor is above the variable name.

Here’s a really simple example:

using UnityEngine;
using UnityEditor;
using System.Collections;

[CanEditMultipleObjects]
[CustomEditor(typeof(MyScript))]
public class MyScriptInspector : Editor
{

	SerializedObject myScriptInstance;
	SerializedProperty myScriptVariableOne;
	SerializedProperty myScriptVariableTwo;
	
	void OnEnable()
	{
		// get a reference to the object currently editing and it's properties
		myScriptInstance = serializedObject;
		myScriptVariableOne = myScriptInstance.FindProperty("varOne");
		myScriptVariableTwo = myScriptInstance.FindProperty("varTwo");
	}
	
	void OnInspectorGUI()
	{
		// get the current state of the object
		myScriptInstance.Update();
		
		// Add additional label, just to show the possibility
		EditorGUILayout.Label("Properties following",GUIStyle.none);
		
		// show inspector fields for properties loaded earlier
		EditorGUILayout.PropertyField(myScriptVariableOne, new GUIContent("The name of the variable in the inspector goes here","The mouse-over description text goes here."), true);
		EditorGUILayout.PropertyField(myScriptVariableTwo, new GUIContent("The name of the variable in the inspector goes here","The mouse-over description text goes here."), true);
		
		// set any changes back to the object
		myScriptInstance.ApplyModifiedProperties();
	}

}

Also this has one major advantage compared to using target, targets or similar: You can easily change any object made from a prefab in the scene without messing up the prefab itself (as long as it is marked as serializable). This is not the case with the other approaches.

(Note: Don’t have Unity here right now so I’m sorry if there are any errors in the script :wink: )

Thanks everyone!