Notes
From Unify Community Wiki
(Difference between revisions)
m (Text replace - "<csharp>" to "<syntaxhighlight lang="csharp">") |
m (incorrect author) |
||
(5 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
− | Author: Jeremy Hollingsworth (jeremyace) | + | C# Author: Jeremy Hollingsworth (jeremyace) |
== Description == | == Description == | ||
Line 7: | Line 7: | ||
== Usage == | == Usage == | ||
− | Place NoteEditor | + | Place NoteEditor in the Editor folder in your assets folder. |
− | Place Note | + | Place Note in your chosen script folder. |
− | To add a note, simply drag Note.cs to your object and type away. | + | To add a note, simply drag Note.cs or Note.js to your object and type away. |
− | Warning: | + | Warning: The C# script uses unsupported code, so use at your own risk. |
== C# - NoteEditor.cs == | == C# - NoteEditor.cs == | ||
Line 41: | Line 41: | ||
myStyle.wordWrap = true; | myStyle.wordWrap = true; | ||
myStyle.stretchWidth = false; | myStyle.stretchWidth = false; | ||
− | note.text = GUILayout.TextArea(note.text, myStyle, GUILayout.Width(200.0F), GUILayout.ExpandWidth( | + | myStyle.normal.textColor = Color.gray; |
+ | note.text = GUILayout.TextArea(note.text, myStyle, GUILayout.Width(200.0F), GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true)); | ||
GUILayout.EndScrollView(); | GUILayout.EndScrollView(); | ||
Repaint(); | Repaint(); | ||
} | } | ||
} | } | ||
− | </ | + | </syntaxhighlight> |
== C# - Note.cs == | == C# - Note.cs == | ||
Line 56: | Line 57: | ||
public string text = "Type your note here"; | public string text = "Type your note here"; | ||
} | } | ||
− | </ | + | </syntaxhighlight> |
− | + | == JS - NoteEditor.js == | |
− | + | <syntaxhighlight lang="javascript"> | |
+ | |||
+ | CustomEditor(Note); | ||
+ | |||
+ | private var note : Note; | ||
+ | |||
+ | private var scrollPos : Vector2; | ||
+ | |||
+ | function OnInspectorGUI () | ||
+ | { | ||
+ | scrollPos = GUILayout.BeginScrollView(scrollPos, GUILayout.Height(100.0)); | ||
+ | var myStyle : GUIStyle; | ||
+ | myStyle.wordWrap = true; | ||
+ | myStyle.stretchWidth = false; | ||
+ | myStyle.normal.textColor = Color.gray; | ||
+ | note.text = GUILayout.TextArea(note.text, myStyle, GUILayout.Width(200.0), GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true)); | ||
+ | GUILayout.EndScrollView(); | ||
+ | this.Repaint(); | ||
+ | } | ||
+ | |||
+ | </syntaxhighlight> | ||
+ | |||
+ | |||
+ | == JS - Note.js == | ||
+ | <syntaxhighlight lang="javascript"> | ||
+ | public class Note extends MonoBehaviour | ||
+ | { | ||
+ | public var text : String = "Type your note here"; | ||
+ | } | ||
+ | </syntaxhighlight> |
Latest revision as of 04:38, 15 November 2015
C# Author: Jeremy Hollingsworth (jeremyace)
Contents |
[edit] Description
Allows you to add a custom note field to any GameObject.
[edit] Usage
Place NoteEditor in the Editor folder in your assets folder.
Place Note in your chosen script folder.
To add a note, simply drag Note.cs or Note.js to your object and type away.
Warning: The C# script uses unsupported code, so use at your own risk.
[edit] 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; myStyle.normal.textColor = Color.gray; note.text = GUILayout.TextArea(note.text, myStyle, GUILayout.Width(200.0F), GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true)); GUILayout.EndScrollView(); Repaint(); } }
[edit] C# - Note.cs
using UnityEngine; public class Note : MonoBehaviour { public string text = "Type your note here"; }
[edit] JS - NoteEditor.js
CustomEditor(Note); private var note : Note; private var scrollPos : Vector2; function OnInspectorGUI () { scrollPos = GUILayout.BeginScrollView(scrollPos, GUILayout.Height(100.0)); var myStyle : GUIStyle; myStyle.wordWrap = true; myStyle.stretchWidth = false; myStyle.normal.textColor = Color.gray; note.text = GUILayout.TextArea(note.text, myStyle, GUILayout.Width(200.0), GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true)); GUILayout.EndScrollView(); this.Repaint(); }
[edit] JS - Note.js
public class Note extends MonoBehaviour { public var text : String = "Type your note here"; }