public override void OnInspectorGUI() { SimpleNoteAttribute attribute = (SimpleNoteAttribute)PropertyAttribute.GetCustomAttribute(monoBehaviour.GetType(), typeof(SimpleNoteAttribute)); if (attribute != null) { GUIStyle textField = new GUIStyle(EditorStyles.textField); textField.fontStyle = FontStyle.Bold; if (GUI.GetNameOfFocusedControl() != "Title" + monoBehaviour.gameObject.GetInstanceID()) { textField.normal = EditorStyles.label.normal; } EditorGUILayout.BeginHorizontal(); GUI.SetNextControlName("Title" + monoBehaviour.gameObject.GetInstanceID()); title = EditorGUILayout.TextField(title, textField); if (GUI.GetNameOfFocusedControl() == "Title" + monoBehaviour.gameObject.GetInstanceID()) { if (GUILayout.Button("Save", GUILayout.Height(15), GUILayout.Width(45))) { EditorPrefs.SetString(monoBehaviour.GetInstanceID() + "-SimpleNote-Title", title); GUI.FocusControl(null); } } EditorGUILayout.EndHorizontal(); GUIStyle textArea = new GUIStyle(EditorStyles.textArea); textArea.richText = true; if (GUI.GetNameOfFocusedControl() != "Note" + monoBehaviour.gameObject.GetInstanceID()) { textArea.normal = EditorStyles.label.normal; } EditorGUILayout.BeginHorizontal(); GUI.SetNextControlName("Note" + monoBehaviour.gameObject.GetInstanceID()); note = EditorGUILayout.TextArea(note, textArea); if (GUI.GetNameOfFocusedControl() == "Note" + monoBehaviour.gameObject.GetInstanceID()) { if (GUILayout.Button("Save", GUILayout.Height(15), GUILayout.Width(45))) { EditorPrefs.SetString(monoBehaviour.GetInstanceID() + "-SimpleNote-Note", note); GUI.FocusControl(null); } } EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); EditorGUI.DrawRect(GUILayoutUtility.GetLastRect(), SimpleNoteData.Instance.getBgColor1); } DrawDefaultInspector(); }
public override void OnInspectorGUI() { if (monoBehaviour == null) { monoBehaviour = (MonoBehaviour)target; } SimpleNoteAttribute attribute = (SimpleNoteAttribute)PropertyAttribute.GetCustomAttribute(monoBehaviour.GetType(), typeof(SimpleNoteAttribute)); if (attribute != null) { //Check if note stored to manager; if (SimpleNoteManager.Instance == null) { SimpleNoteManager.Init(); } if (SimpleNoteManager.Instance.getIndexAttributeScriptNote(monoBehaviour.gameObject, monoBehaviour) == -1) { if (string.IsNullOrEmpty(attribute.title) && string.IsNullOrEmpty(attribute.note)) { SimpleNoteManager.Instance.attScriptNote.Add(new SimpleNoteManager.AttributeScriptNote(monoBehaviour.gameObject, monoBehaviour, title, note)); } else { SimpleNoteManager.Instance.attScriptNote.Add(new SimpleNoteManager.AttributeScriptNote(monoBehaviour.gameObject, monoBehaviour, attribute.title, attribute.note)); title = attribute.title; note = attribute.note; } } if (index == -1) { index = SimpleNoteManager.Instance.getIndexAttributeScriptNote(monoBehaviour.gameObject, monoBehaviour); } GUIStyle textField = new GUIStyle(EditorStyles.textField); textField.fontStyle = FontStyle.Bold; if (GUI.GetNameOfFocusedControl() != "Title" + monoBehaviour.gameObject.GetInstanceID()) { textField.normal = EditorStyles.label.normal; } EditorGUILayout.BeginHorizontal(); title = EditorGUILayout.TextField(title, textField); //EditorPrefs.SetString(monoBehaviour.GetInstanceID() + "-SimpleNote-Title", title); if (SimpleNoteManager.Instance.attScriptNote[index].note.title != title) { SimpleNoteManager.Instance.attScriptNote[index].note.title = title; } EditorGUILayout.EndHorizontal(); GUIStyle textArea = new GUIStyle(EditorStyles.textArea); textArea.richText = true; if (GUI.GetNameOfFocusedControl() != "Note" + monoBehaviour.gameObject.GetInstanceID()) { textArea.normal = EditorStyles.label.normal; } EditorGUILayout.BeginHorizontal(); note = EditorGUILayout.TextArea(note, textArea); //EditorPrefs.SetString(monoBehaviour.GetInstanceID() + "-SimpleNote-Note", note); if (SimpleNoteManager.Instance.attScriptNote[index].note.note != note) { SimpleNoteManager.Instance.attScriptNote[index].note.note = note; } EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); EditorGUI.DrawRect(GUILayoutUtility.GetLastRect(), SimpleNoteData.Instance.getBgColor1); } DrawDefaultInspector(); }