Notes
From Unify Community Wiki
(Difference between revisions)
m (Text replace - "<csharp>" to "<syntaxhighlight lang="csharp">") |
m (Text replace - "</csharp>" to "</syntaxhighlight>") |
||
Line 46: | Line 46: | ||
} | } | ||
} | } | ||
− | </ | + | </syntaxhighlight> |
== C# - Note.cs == | == C# - Note.cs == | ||
Line 56: | Line 56: | ||
public string text = "Type your note here"; | public string text = "Type your note here"; | ||
} | } | ||
− | </ | + | </syntaxhighlight> |
[[Category:Editor Scripts]] | [[Category:Editor Scripts]] | ||
[[Category:C Sharp]] | [[Category:C Sharp]] |
Revision as of 20:45, 10 January 2012
Author: Jeremy Hollingsworth (jeremyace)
Contents |
Description
Allows you to add a custom note field to any GameObject.
Usage
Place NoteEditor.cs in the Editor folder in your assets folder.
Place Note.cs in your chosen script folder.
To add a note, simply drag Note.cs to your object and type away.
Warning: This script uses unsupported code, so use at your own risk.
C# - NoteEditor.cs
using UnityEditor; using UnityEngine; using System; [CustomEditor(typeof(Note))] public class NoteEditor : Editor { private Note note; private Vector2 scrollPos; private void Init() { note = base.target as Note; } void OnInspectorGUI() { Init(); scrollPos = GUILayout.BeginScrollView(scrollPos, GUILayout.Height(100.0F)); GUIStyle myStyle = new GUIStyle(); myStyle.wordWrap = true; myStyle.stretchWidth = false; note.text = GUILayout.TextArea(note.text, myStyle, GUILayout.Width(200.0F), GUILayout.ExpandWidth(false), GUILayout.ExpandHeight(true)); GUILayout.EndScrollView(); Repaint(); } }
C# - Note.cs
using UnityEngine; public class Note : MonoBehaviour { public string text = "Type your note here"; }