private void DrawUserDataArea() { //Toolbar GUILayout.BeginHorizontal(EditorStyles.toolbar); GUILayout.Space(-4); GUILayout.Label(userData, EditorStyles.toolbarButton); GUILayout.FlexibleSpace(); if (haveUserData && GUILayout.Button("Remove text", EditorStyles.toolbarButton)) { haveUserData = false; clip.userdata = ""; EditorUtility.SetDirty(clip); } if (!haveUserData && GUILayout.Button("Add text", EditorStyles.toolbarButton)) { haveUserData = true; } int id = 0; if (GUILayout.Button("Add Label", EditorStyles.toolbarButton)) { string name = "New label"; while (clip.ContainsLabel(name)) { id++; name = "New Label " + id; } ArrayUtility.Add(ref clip.labels, new Label(name, 0)); EditorUtility.SetDirty(clip); } GUILayout.Space(-4); GUILayout.EndHorizontal(); //User data string if (haveUserData) { GUILayout.Space(10); clip.userdata = GUILayout.TextArea(clip.userdata, GUILayout.MinHeight(100)); } //Draw labels if (clip.labels != null && clip.labels.Length > 0) { GUILayout.Space(10); int count = clip.labels.Length; for (int i = 0; i < count; i++) { EditorGUI.BeginChangeCheck(); GUILayout.BeginHorizontal(); string labelText = GUILayout.TextField(clip.labels[i].text); int labelValue = EditorGUILayout.IntField(clip.labels[i].value, GUILayout.Width(50)); bool delete = GUILayout.Button("X", GUILayout.Width(20)); GUILayout.EndHorizontal(); if (EditorGUI.EndChangeCheck()) { if (delete) { ArrayUtility.RemoveAt(ref clip.labels, i); count--; i--; } else { clip.labels[i] = new Label(labelText, labelValue); EditorUtility.SetDirty(clip); } } } GUILayout.Space(10); } else if (!haveUserData) { GUILayout.Space(10); } }