Notes

From Unify Community Wiki
(Difference between revisions)
Jump to: navigation, search
(Removed debug var)
m (Text replace - "<csharp>" to "<syntaxhighlight lang="csharp">")
Line 17: Line 17:
 
== C# - NoteEditor.cs ==
 
== C# - NoteEditor.cs ==
  
<csharp>
+
<syntaxhighlight lang="csharp">
 
using UnityEditor;
 
using UnityEditor;
 
using UnityEngine;
 
using UnityEngine;
Line 49: Line 49:
  
 
== C# - Note.cs ==
 
== C# - Note.cs ==
<csharp>
+
<syntaxhighlight lang="csharp">
 
using UnityEngine;
 
using UnityEngine;
  

Revision as of 20:43, 10 January 2012

Author: Jeremy Hollingsworth (jeremyace)

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();       
    }          
}
</csharp>
 
== C# - Note.cs ==
<syntaxhighlight lang="csharp">
using UnityEngine;
 
public class Note : MonoBehaviour
{
    public string text = "Type your note here";
} 
</csharp>
 
[[Category:Editor Scripts]]
[[Category:C Sharp]]
Personal tools
Namespaces

Variants
Actions
Navigation
Extras
Toolbox