- Home /
Adding notes to the inspector?
I found this: [http://wiki.unity3d.com/index.php?title=Notes][1]
It allows you to add notes, but only a one line note can be added (the text does not wrap). Can this be edited to allow more lines of writing?
Thanks [1]: http://wiki.unity3d.com/index.php?title=Notes
Answer by AlanMattano · Aug 29, 2014 at 01:38 AM
Just download this new free tool from the asset store. link: https://www.assetstore.unity3d.com/en/#!/content/51884
**strong text**Look this example: link: http://forum.unity3d.com/threads/add-info-text-notes-into-the-inspector.265330/
Make a C# script name InfoTextNote.
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class InfoTextNote : MonoBehaviour
{
public bool isReady = true;
public string TextInfo = "Text here... " + "/n Lock when finish.";
public void SwitchToggle ()
{
isReady = !isReady;
}
void Start ()
{
this.enabled = false; // Disable the component when the game start
}
}
Then make a folder and name it "Editor". In it make a new C# name AddInspectorText
using UnityEngine;
using System.Collections;
using UnityEditor;
/* *Made by AlanMattano }} 2014* */
[CustomEditor(typeof(InfoTextNote))]
public class AddInspectorText : Editor {
private int c = 0;
private string buttonText = "Start Writting";
private int MaxSizeInt = 5;
private int[] IntArray = new int[] { 0, 1, 2, 3, 4 };
private string[] MaxSizeString = new string[] { "Line Label", "Box Text ", "Box Info", "Box Warning", "Box Error" };
public override void OnInspectorGUI()
{
InfoTextNote inMyScript = (InfoTextNote)target; //
if ( inMyScript.TextInfo == "Start writting text here... " +
"/n Press Lock when finish." )
ShowLogMessage() ;// se podria agregar alguna funcin en especial
if ( !inMyScript.isReady ) {
// The user is writing the text in this inspector editor.
//DrawDefaultInspector(); // Unity function: add all is in the inspector
switch (MaxSizeInt)
{
case 0:
if (EditorGUILayout.Toggle(inMyScript.isReady))inMyScript.SwitchToggle(); // Toggle
EditorGUILayout.LabelField(inMyScript.TextInfo); // This is a small line text
break;
case 1:
if ( GUILayout.Button(buttonText)) inMyScript.SwitchToggle(); // Button
EditorGUILayout.HelpBox(inMyScript.TextInfo, MessageType.None); // This is a small box
break;
case 2:
if ( GUILayout.Button(buttonText)) inMyScript.SwitchToggle(); // Button
EditorGUILayout.HelpBox(inMyScript.TextInfo, MessageType.Info); // This is a help box
break;
case 3:
if ( GUILayout.Button(buttonText)) inMyScript.SwitchToggle(); // Button
EditorGUILayout.HelpBox(inMyScript.TextInfo, MessageType.Warning); // This is a Warning box
break;
case 4:
if ( GUILayout.Button(buttonText)) inMyScript.SwitchToggle(); // Button
EditorGUILayout.HelpBox(inMyScript.TextInfo, MessageType.Error); // This is a Error box
break;
default:
if ( GUILayout.Button(buttonText)) inMyScript.SwitchToggle(); // Button
EditorGUILayout.HelpBox(inMyScript.TextInfo, MessageType.Info); // This is a help box
break;
}
}else{
// The user is writing the text in this inspector editor
//DrawDefaultInspector();// for debug
buttonText = "Lock !";
// Button
if ( GUILayout.Button(buttonText)) inMyScript.SwitchToggle();
// Text
inMyScript.TextInfo = EditorGUILayout.TextArea (inMyScript.TextInfo);
// selection
MaxSizeInt = EditorGUILayout.IntPopup("Text Type :", MaxSizeInt, MaxSizeString, IntArray);
// warning
EditorGUILayout.HelpBox( " Press LOCK at the top when finish. ", MessageType.Warning); // This is a Warning box
}
}
void ShowLogMessage() {
c++;
if (c==1) {
Debug.Log (" Need to add text " + "\n");
}
}
}
Then return to InfoTextNote and add it into the inspector.
Others in the community edit this answer. You can add corrections and improve this script
Answer by usergame · Mar 29, 2017 at 04:37 PM
I realize this is an old question but I was recently looking for a solution to this problem and didn't like the the suggested solutions, so I wrote my own simple PropertyDrawer and PropertyAttribute. Get more information at the forum post:
Hope this helps someone out who is still looking for a solution :)
Your answer
Follow this Question
Related Questions
Notes or Bubble Window for Variables in Inspector Giving Help? 3 Answers
Messing With Gradients At Runtime? 2 Answers
[Uni2D + Unity Inspector] Unity extremely slow, when a Sprite is selected 4 Answers
Inspector scripting, adding lists, checkboxes and buttons [With Image] 0 Answers
Assigning animations in inspector? 1 Answer