private void eventProcess(Event e) { switch (e.type) { case EventType.ContextClick: if (rect.Contains(e.mousePosition)) { IsContextClick = true; e.Use(); } else { IsContextClick = false; } break; default: var obj = FileUtility.GetDraggedObject(e, rect); if (obj != null) { UndoHelper.EditorMemoUndo(UndoHelper.UNDO_MEMO_EDIT); ObjectRef = new UnityEditorMemoObject(); ObjectRef.SetReference(obj); e.Use(); } IsContextClick = false; break; } }
//====================================================================== // Event Process //====================================================================== #region event process void EventProcess(Event e) { if (WindowHelper.Data == null || WindowHelper.CurCategory(selectCategoryId) == null) { return; } var memos = WindowHelper.CurCategory(selectCategoryId).Memo; for (int i = 0; i < memos.Count; i++) { var memo = memos[i]; if (memo.IsContextClick) { var menu = new GenericMenu(); menu.AddItem(new GUIContent("Edit"), false, () => { memo.isFoldout = true; }); menu.AddItem(new GUIContent("Delete"), false, () => { UndoHelper.EditorMemoUndo(UndoHelper.UNDO_DELETE_MEMO); WindowHelper.CurCategory(selectCategoryId).Memo.Remove(memo); }); menu.ShowAsContext(); break; } } }
void LabelGUI() { EditorGUILayout.BeginHorizontal(); { var curToggles = new bool[6]; footerToggle.CopyTo(curToggles, 0); curToggles[0] = GUILayout.Toggle(curToggles[0], "all", EditorStyles.toolbarButton); GUI.backgroundColor = GUIHelper.Colors.LabelColor(1); curToggles[1] = GUILayout.Toggle(curToggles[1], UnityEditorMemoPrefs.Label1, EditorStyles.toolbarButton); GUI.backgroundColor = GUIHelper.Colors.LabelColor(2); curToggles[2] = GUILayout.Toggle(curToggles[2], UnityEditorMemoPrefs.Label2, EditorStyles.toolbarButton); GUI.backgroundColor = GUIHelper.Colors.LabelColor(3); curToggles[3] = GUILayout.Toggle(curToggles[3], UnityEditorMemoPrefs.Label3, EditorStyles.toolbarButton); GUI.backgroundColor = GUIHelper.Colors.LabelColor(4); curToggles[4] = GUILayout.Toggle(curToggles[4], UnityEditorMemoPrefs.Label4, EditorStyles.toolbarButton); GUI.backgroundColor = GUIHelper.Colors.LabelColor(5); curToggles[5] = GUILayout.Toggle(curToggles[5], UnityEditorMemoPrefs.Label5, EditorStyles.toolbarButton); GUI.backgroundColor = Color.white; var label = WindowHelper.ChangeFooterStatus(selectLabel, ref curToggles); if (label != selectLabel) { UndoHelper.WindowUndo(UndoHelper.UNDO_CHANGE_LABEL); // avoid error. why? :( postMemoLabel = label; selectLabel = label; memoTreeView.SelectLabel = ( UnityEditorMemoLabel )selectLabel; memoTreeView.Reload(); GUIUtility.keyboardControl = 0; } footerToggle = curToggles; } EditorGUILayout.EndHorizontal(); }
//======================================================= // drag and drop //======================================================= protected override DragAndDropVisualMode HandleDragAndDrop(DragAndDropArgs args) { // remove item which came from category. var draggedCategory = DragAndDrop.GetGenericData("UnityEditorMemoCategoryDragging"); if (draggedCategory != null) { return(DragAndDropVisualMode.None); } switch (args.dragAndDropPosition) { case DragAndDropPosition.UponItem: { if (args.performDrop) { UndoHelper.EditorMemoUndo(UndoHelper.UNDO_MEMO_EDIT); var target = (TreeViewItem <UnityEditorMemo>)args.parentItem; target.data.ObjectRef = new UnityEditorMemoObject(DragAndDrop.objectReferences[0]); RefreshCustomRowHeights(); } return(DragAndDropVisualMode.Move); } } return(DragAndDropVisualMode.None); }
void CategoryMenu() { var selectedId = 0; EditorGUILayout.BeginHorizontal(EditorStyles.toolbar, GUILayout.ExpandWidth(true)); { //searchText = GUILayout.TextField( searchText, GUIHelper.Styles.SearchField, GUILayout.Width( 200 ) ); //if( GUILayout.Button( "", GUIHelper.Styles.SearchFieldCancel ) ) { // searchText = ""; // GUIUtility.keyboardControl = 0; //} GUILayout.Space(position.width * 0.48f); GUI.backgroundColor = Color.yellow; selectedId = EditorGUILayout.Popup(selectCategoryId, WindowHelper.Data.CategoryList, EditorStyles.toolbarPopup); GUI.backgroundColor = Color.white; } EditorGUILayout.EndHorizontal(); if (selectCategoryId != selectedId) { Undo.IncrementCurrentGroup(); UndoHelper.WindowUndo(UndoHelper.UNDO_CHANGE_CATEGORY); GUIUtility.keyboardControl = 0; selectLabel = 0; footerToggle = new bool[] { true, false, false, false, false, false }; WindowHelper.CurCategory(selectedId).OnCategoryChange(); } selectCategoryId = selectedId; }
public void OnSceneGUI() { EditorGUILayout.BeginVertical(); { // header GUI.backgroundColor = GUIHelper.Colors.SceneMemoLabelColor(Label); EditorGUILayout.BeginHorizontal(GUIHelper.Styles.MemoHeader, new GUILayoutOption[] { GUILayout.ExpandWidth(true) }); { DrawTexture(); GUILayout.Label(Name, GUIHelper.Styles.LabelWordWrap); GUILayout.FlexibleSpace(); if (GUILayout.Button("x", EditorStyles.toolbarButton, new GUILayoutOption[] { GUILayout.Width(18) })) { Undo.IncrementCurrentGroup(); UndoHelper.SceneMemoUndo(UndoHelper.UNDO_SCENEMEMO_EDIT); ShowAtScene = false; } } EditorGUILayout.EndHorizontal(); GUI.backgroundColor = Color.white; // memo GUI.backgroundColor = GUIHelper.Colors.TransparentColor; scrollView = EditorGUILayout.BeginScrollView(scrollView, GUIHelper.Styles.NoSpaceBox); { GUILayout.Label(Memo, GUIHelper.Styles.LabelWordWrap); } EditorGUILayout.EndScrollView(); GUI.backgroundColor = Color.white; } EditorGUILayout.EndVertical(); }
public static void OnGUI(int instanceID, Rect selectionRect) { if (Application.isPlaying) { return; } var obj = EditorUtility.InstanceIDToObject(instanceID); if (obj == null) { return; } var localIdentifier = UnitySceneMemoHelper.GetLocalIdentifierInFile(obj); if (localIdentifier == 0) { return; } if (IsNoSelection) { currentMemo = null; } var gameObject = obj as GameObject; var buttonRect = ButtonRect(selectionRect, gameObject.transform.childCount > 0); var isSelected = CheckSelected(instanceID); var memo = UnitySceneMemoHelper.GetMemo(gameObject, localIdentifier); if (memo == null) { if (isSelected) { if (GUI.Button(buttonRect, "")) { UndoHelper.SceneMemoUndo(UndoHelper.UNDO_SCENEMEMO_ADD); UnitySceneMemoHelper.AddMemo(obj as GameObject, localIdentifier); } GUI.Label(buttonRect, "+"); } } else { if (isSelected) { currentMemo = memo; } GUI.color = GUIHelper.Colors.LabelColor(memo.Label); GUI.DrawTexture(buttonRect, GUIHelper.Textures.Balloon); if (GUI.Button(buttonRect, "", GUIStyle.none)) { UnitySceneMemoHelper.PopupWindowContent.Initialize(memo); PopupWindow.Show(selectionRect, UnitySceneMemoHelper.PopupWindowContent); } GUI.color = Color.white; SceneView.RepaintAll(); } }
private void OnCategoryDelete(UnityEditorMemoCategory category) { UndoHelper.EditorMemoUndo(UndoHelper.UNDO_DELETE_CATEGORY); WindowHelper.Data.Category.Remove(category); CategoryTreeViewInitialize(); MemoTreeViewInitialize(); }
private void OnMemoDelete(UnityEditorMemo memo) { UndoHelper.EditorMemoUndo(UndoHelper.UNDO_DELETE_MEMO); WindowHelper.GetCategory(selectCategoryId).Memo.Remove(memo); EditorUtility.SetDirty(WindowHelper.Data); MemoTreeViewInitialize(); }
private void OnMemoOrderChanged(List <UnityEditorMemo> newMemos) { UndoHelper.EditorMemoUndo(UndoHelper.UNDO_MEMO_EDIT); var currentCategory = WindowHelper.GetCategory(selectCategoryId); currentCategory.Memo = newMemos; Initialize(); }
protected override DragAndDropVisualMode HandleDragAndDrop(DragAndDropArgs args) { // remove item which came from category. var draggedCategory = DragAndDrop.GetGenericData("UnityEditorMemoCategoryDragging"); if (draggedCategory != null) { return(DragAndDropVisualMode.None); } var draggedMemo = DragAndDrop.GetGenericData("UnityEditorMemoDragging"); if (draggedMemo != null) { //var draggedItem = draggedMemo as List<TreeViewItem>; switch (args.dragAndDropPosition) { case DragAndDropPosition.BetweenItems: { //var validDrag = isValidDrag( args.parentItem, draggedItem ); //if ( args.performDrop && validDrag ) // OnDropDraggedElementsAtIndex( draggedItem, ( TreeViewItem )args.parentItem, args.insertAtIndex == -1 ? 0 : args.insertAtIndex ); return(DragAndDropVisualMode.None); } //case DragAndDropPosition.OutsideItems: // { // if ( args.performDrop ) // OnDropDraggedElementsAtIndex( draggedItem, rootItem, 1 ); // return DragAndDropVisualMode.Move; // } } } else { // asset dragging switch (args.dragAndDropPosition) { case DragAndDropPosition.UponItem: { if (args.performDrop) { UndoHelper.EditorMemoUndo(UndoHelper.UNDO_MEMO_EDIT); var target = (TreeViewItem <UnityEditorMemo>)args.parentItem; target.data.ObjectRef = new UnityEditorMemoObject(DragAndDrop.objectReferences[0]); RefreshCustomRowHeights(); } return(DragAndDropVisualMode.Move); } } } return(DragAndDropVisualMode.None); }
protected override void DoubleClickedItem(int id) { Undo.IncrementCurrentGroup(); UndoHelper.EditorMemoUndo(UndoHelper.UNDO_MEMO_EDIT); var item = FindItem(id, rootItem); var target = (TreeViewItem <UnityEditorMemo>)item; target.data.IsEdit = !target.data.IsEdit; RefreshCustomRowHeights(); }
private void OnCategoryCreate() { UndoHelper.EditorMemoUndo(UndoHelper.UNDO_CREATE_CATEGORY); var newCategory = new UnityEditorMemoCategory("new Category"); WindowHelper.Data.AddCategory(newCategory); CategoryTreeViewInitialize(); categoryTreeView.BeginRename(newCategory); }
private void OnCategoryChange() { Undo.IncrementCurrentGroup(); UndoHelper.WindowUndo(UndoHelper.UNDO_CHANGE_CATEGORY); selectLabel = 0; footerToggle = new bool[] { true, false, false, false, false, false }; WindowHelper.GetCategory(selectCategoryId).Initialize(); MemoTreeViewInitialize(); EditorGUIUtility.keyboardControl = 0; }
public void OnGUI() { rect = EditorGUILayout.BeginVertical(); { // header GUI.backgroundColor = GUIHelper.Colors.LabelColor(Label); EditorGUILayout.BeginHorizontal(GUIHelper.Styles.MemoHeader, new GUILayoutOption[] { GUILayout.ExpandWidth(true) }); { DrawTexture(); GUILayout.Label(Name, GUIHelper.Styles.LabelWordWrap); GUILayout.FlexibleSpace(); var edit = GUILayout.Toggle(isEdit, "≡", EditorStyles.toolbarButton, new GUILayoutOption[] { GUILayout.Width(18) }); if (edit != isEdit) { GUIUtility.keyboardControl = 0; } isEdit = edit; } EditorGUILayout.EndHorizontal(); GUI.backgroundColor = Color.white; // memo scrollView = EditorGUILayout.BeginScrollView(scrollView); if (isEdit) { Undo.IncrementCurrentGroup(); UndoHelper.SceneMemoUndo(UndoHelper.UNDO_SCENEMEMO_EDIT); Memo = EditorGUILayout.TextArea(Memo, GUIHelper.Styles.TextAreaWordWrap, new GUILayoutOption[] { GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true) }); } else { GUILayout.Label(Memo, GUIHelper.Styles.LabelWordWrap); } EditorGUILayout.EndScrollView(); // footer if (isEdit) { GUILayout.Space(5); EditorGUILayout.BeginHorizontal(); { GUILayout.FlexibleSpace(); ShowAtScene = GUILayout.Toggle(ShowAtScene, "ShowAtScene", GUI.skin.button, GUILayout.Width(100f)); Label = ( UnityEditorMemoLabel )EditorGUILayout.Popup(( int )Label, GUIHelper.Label, GUILayout.Width(70)); } EditorGUILayout.EndHorizontal(); GUILayout.Space(5); } } EditorGUILayout.EndVertical(); IsContextClick = eventProcess(Event.current); }
private bool ObjectReferenceGUI(Rect rect) { var obj = ObjectRef.Obj; if (ObjectRef.HasReferenceObject()) { var objectRect = rect; objectRect.width = IsEdit ? objectRect.width - 70f : objectRect.width; objectRect.y += EditorGUIUtility.standardVerticalSpacing + rect.height; objectRect.height = EditorGUIUtility.singleLineHeight; if (obj != null) { //Undo.IncrementCurrentGroup(); //UndoHelper.EditorMemoUndo( UndoHelper.UNDO_MEMO_EDIT ); ObjectRef.Obj = EditorGUI.ObjectField(objectRect, ObjectRef.Obj, typeof(Object), true); } else { var buttonWidth = EditorStyles.objectField.CalcSize(new GUIContent(ObjectRef.SceneMemo.ObjectName)); objectRect.width = buttonWidth.x; if (GUI.Button(objectRect, ObjectRef.SceneMemo.ObjectName, EditorStyles.objectField)) { UnitySceneMemoHelper.PopupWindowContent.Initialize(ObjectRef.SceneMemo); PopupWindow.Show(rect, UnitySceneMemoHelper.PopupWindowContent); } var textureRect = objectRect; textureRect.xMin += buttonWidth.x; drawComponent(textureRect, ObjectRef.SceneMemo.Components); } if (IsEdit) { var buttonRect = objectRect; buttonRect.x = objectRect.xMax; buttonRect.width = 70f; if (GUI.Button(buttonRect, "clear")) { UndoHelper.EditorMemoUndo(UndoHelper.UNDO_MEMO_EDIT); ObjectRef.Obj = null; ObjectRef.ScenePath = null; ObjectRef.SceneMemo = null; ObjectRef.LocalIdentifierInFile = 0; GUIUtility.keyboardControl = 0; } } return(true); } else { return(false); } }
private void OnMemoPost(UnityEditorMemoCategory category, UnityEditorMemo memo) { UndoHelper.EditorMemoUndo(UndoHelper.UNDO_POST); category.AddMemo(memo); category.Initialize(); memoText = ""; postMemoTex = 0; postMemoUrl = ""; if (selectLabel == 0) { postMemoLabel = 0; } GUIUtility.keyboardControl = 0; MemoTreeViewInitialize(); }
public void Draw(bool isFold) { if (Obj != null) { EditorGUILayout.BeginHorizontal(); { GUILayout.Space(41); UndoHelper.EditorMemoUndo(UndoHelper.UNDO_MEMO_EDIT); Obj = EditorGUILayout.ObjectField("", Obj, typeof(Object), true); if (isFold) { if (GUILayout.Button("clear", GUILayout.Width(70))) { UndoHelper.EditorMemoUndo(UndoHelper.UNDO_MEMO_EDIT); clearReference(); GUIUtility.keyboardControl = 0; } } } EditorGUILayout.EndHorizontal(); } else if (isSceneMemoValid) { var rect = EditorGUILayout.BeginHorizontal(); { GUILayout.Space(41); UndoHelper.EditorMemoUndo(UndoHelper.UNDO_MEMO_EDIT); SceneMemo.DrawTexture(); if (GUILayout.Button(SceneMemo.Name, GUI.skin.label)) { SceneMemo.SelectObject(); UnitySceneMemoHelper.PopupWindowContent.Initialize(SceneMemo); PopupWindow.Show(rect, UnitySceneMemoHelper.PopupWindowContent); } if (isFold) { if (GUILayout.Button("clear", GUILayout.Width(70))) { UndoHelper.EditorMemoUndo(UndoHelper.UNDO_MEMO_EDIT); clearReference(); GUIUtility.keyboardControl = 0; } } } EditorGUILayout.EndHorizontal(); } }
public void OnSceneGUI() { EditorGUILayout.BeginVertical(); { // header GUI.backgroundColor = GUIHelper.Colors.SceneMemoLabelColor(Label); EditorGUILayout.BeginHorizontal(GUIHelper.Styles.MemoHeader); { if (GUILayout.Button(InVisible ? "●" : "x", EditorStyles.toolbarButton, new GUILayoutOption[] { GUILayout.Width(18) })) { Undo.IncrementCurrentGroup(); UndoHelper.SceneMemoUndo(UndoHelper.UNDO_SCENEMEMO_EDIT); InVisible = !InVisible; } EditorGUILayout.BeginHorizontal(); { DrawTexture(); GUILayout.Label(Name); } EditorGUILayout.EndHorizontal(); GUILayout.FlexibleSpace(); } EditorGUILayout.EndHorizontal(); GUI.backgroundColor = Color.white; if (!InVisible) { // memo GUI.backgroundColor = GUIHelper.Colors.TransparentColor; scrollView = EditorGUILayout.BeginScrollView(scrollView, GUIHelper.Styles.NoSpaceBox); { GUIHelper.Styles.LabelWordWrap.normal.textColor = GUIHelper.Colors.SceneMemoTextColor(TextCol); GUILayout.Label(Memo, GUIHelper.Styles.LabelWordWrap); GUIHelper.Styles.LabelWordWrap.normal.textColor = GUIHelper.Colors.DefaultTextColor; } EditorGUILayout.EndScrollView(); GUI.backgroundColor = Color.white; } } EditorGUILayout.EndVertical(); }
private void OnUnityEditorMemoImport(bool isOverride) { var text = FileUtility.ImportUnityEditorMemoData(); var data = JsonUtility.FromJson <UnityEditorMemoExport>(text); if (data == null) { return; } UndoHelper.EditorMemoUndo(UndoHelper.UNDO_IMPORT_MEMO); if (isOverride) { WindowHelper.Data.Category = data.category.ToList(); } else { data.category.ToList().RemoveAll(c => c.Name == "default"); WindowHelper.Data.Category.AddRange(data.category.ToList()); } Initialize(); }
private void labelSelectionGUI(Rect rect) { var curToggles = new bool[6]; footerToggle.CopyTo(curToggles, 0); rect.width = rect.width / 6; rect.height = 15f; GUI.backgroundColor = Color.white; curToggles[0] = GUI.Toggle(rect, curToggles[0], "", GUIHelper.Styles.LargeButtonLeft); rect.x += rect.width; GUI.backgroundColor = GUIHelper.Colors.LabelColor(1); curToggles[1] = GUI.Toggle(rect, curToggles[1], "", GUIHelper.Styles.LargeButtonMid); rect.x += rect.width; GUI.backgroundColor = GUIHelper.Colors.LabelColor(2); curToggles[2] = GUI.Toggle(rect, curToggles[2], "", GUIHelper.Styles.LargeButtonMid); rect.x += rect.width; GUI.backgroundColor = GUIHelper.Colors.LabelColor(3); curToggles[3] = GUI.Toggle(rect, curToggles[3], "", GUIHelper.Styles.LargeButtonMid); rect.x += rect.width; GUI.backgroundColor = GUIHelper.Colors.LabelColor(4); curToggles[4] = GUI.Toggle(rect, curToggles[4], "", GUIHelper.Styles.LargeButtonMid); rect.x += rect.width; GUI.backgroundColor = GUIHelper.Colors.LabelColor(5); curToggles[5] = GUI.Toggle(rect, curToggles[5], "", GUIHelper.Styles.LargeButtonRight); rect.x += rect.width; GUI.backgroundColor = Color.white; var label = ( UnityEditorMemoLabel )WindowHelper.ChangeFooterStatus((int)Label, ref curToggles); if (label != Label) { UndoHelper.EditorMemoUndo(UndoHelper.UNDO_CHANGE_LABEL); Label = label; } footerToggle = curToggles; }
void CategoryMenu() { var selectedId = 0; EditorGUILayout.BeginHorizontal(GUIHelper.Styles.NoSpaceBox, GUILayout.ExpandWidth(true)); { GUILayout.Label("Category".ToBold()); GUI.backgroundColor = Color.yellow; selectedId = EditorGUILayout.Popup(selectCategoryId, WindowHelper.Data.CategoryList, EditorStyles.toolbarPopup); GUI.backgroundColor = Color.white; } EditorGUILayout.EndHorizontal(); if (selectCategoryId != selectedId) { Undo.IncrementCurrentGroup(); UndoHelper.WindowUndo(UndoHelper.UNDO_CHANGE_CATEGORY); GUIUtility.keyboardControl = 0; selectLabel = 0; footerToggle = new bool[] { true, false, false, false, false, false }; WindowHelper.CurCategory(selectCategoryId).OnCategoryChange(); } selectCategoryId = selectedId; }
private void OnMemoContextClicked(UnityEditorMemo memo) { var menu = new GenericMenu(); menu.AddItem(new GUIContent(!memo.IsEdit ? "Edit" : "Done"), false, () => { UndoHelper.EditorMemoUndo(UndoHelper.UNDO_MEMO_EDIT); memo.IsEdit = !memo.IsEdit; memoTreeView.UpdateRowHeight(); }); menu.AddItem(new GUIContent("Repost"), false, () => { OnMemoDelete(memo); memo.Date = DateTime.Now.RenderDate(); OnMemoPost(WindowHelper.GetCategory(selectCategoryId), memo); }); if (!string.IsNullOrEmpty(UnityEditorMemoPrefs.Label1)) { menu.AddItem(new GUIContent("Label/" + UnityEditorMemoPrefs.Label1), memo.Label == 0, () => { UndoHelper.EditorMemoUndo(UndoHelper.UNDO_MEMO_EDIT); memo.Label = 0; }); } if (!string.IsNullOrEmpty(UnityEditorMemoPrefs.Label2)) { menu.AddItem(new GUIContent("Label/" + UnityEditorMemoPrefs.Label2), ( int )memo.Label == 1, () => { UndoHelper.EditorMemoUndo(UndoHelper.UNDO_MEMO_EDIT); memo.Label = ( UnityEditorMemoLabel )1; }); } if (!string.IsNullOrEmpty(UnityEditorMemoPrefs.Label3)) { menu.AddItem(new GUIContent("Label/" + UnityEditorMemoPrefs.Label3), ( int )memo.Label == 2, () => { UndoHelper.EditorMemoUndo(UndoHelper.UNDO_MEMO_EDIT); memo.Label = ( UnityEditorMemoLabel )2; }); } if (!string.IsNullOrEmpty(UnityEditorMemoPrefs.Label4)) { menu.AddItem(new GUIContent("Label/" + UnityEditorMemoPrefs.Label4), ( int )memo.Label == 3, () => { UndoHelper.EditorMemoUndo(UndoHelper.UNDO_MEMO_EDIT); memo.Label = ( UnityEditorMemoLabel )3; }); } if (!string.IsNullOrEmpty(UnityEditorMemoPrefs.Label5)) { menu.AddItem(new GUIContent("Label/" + UnityEditorMemoPrefs.Label5), ( int )memo.Label == 5, () => { UndoHelper.EditorMemoUndo(UndoHelper.UNDO_MEMO_EDIT); memo.Label = ( UnityEditorMemoLabel )5; }); } menu.AddSeparator(""); if (!string.IsNullOrEmpty(memo.URL)) { menu.AddItem(new GUIContent("Open URL"), false, () => { Application.OpenURL(memo.URL); }); menu.AddSeparator(""); } menu.AddItem(new GUIContent("Delete"), false, () => { OnMemoDelete(memo); }); menu.ShowAsContext(); }
void CategoryContents() { GUILayout.Label(WindowHelper.TEXT_CATEGORY_DESC); EditorGUILayout.BeginHorizontal(); { GUI.skin.textField.alignment = TextAnchor.MiddleLeft; categoryName = EditorGUILayout.TextField(categoryName, new GUILayoutOption[] { GUILayout.Height(30) }); GUI.skin.textField.alignment = TextAnchor.UpperLeft; GUI.backgroundColor = Color.green; if (GUILayout.Button("Register", new GUILayoutOption[] { GUILayout.Height(30), GUILayout.Width(100) })) { if (string.IsNullOrEmpty(categoryName)) { Debug.LogWarning(WindowHelper.WARNING_CATEGORY_EMPTY); } else { UndoHelper.EditorMemoUndo(UndoHelper.UNDO_CREATE_CATEGORY); WindowHelper.Data.AddCategory(new UnityEditorMemoCategory(categoryName)); categoryName = ""; GUIUtility.keyboardControl = 0; EditorUtility.SetDirty(WindowHelper.Data); AssetDatabase.SaveAssets(); } } GUI.backgroundColor = Color.white; } EditorGUILayout.EndHorizontal(); GUILayout.Space(5); categoryScrollView = EditorGUILayout.BeginScrollView(categoryScrollView); { GUI.backgroundColor = Color.grey; EditorGUILayout.BeginHorizontal(GUI.skin.box, new GUILayoutOption[] { GUILayout.Height(20), GUILayout.ExpandWidth(true) }); { GUILayout.Label("CategoryName", GUILayout.ExpandWidth(true)); GUILayout.Label("Num", GUILayout.Width(50)); GUILayout.Label("Last Posted", GUILayout.Width(120)); var isEdit = GUILayout.Toggle(categoryEdit, "≡", EditorStyles.toolbarButton, GUILayout.Width(20)); if (isEdit != categoryEdit) { UndoHelper.EditorMemoUndo(UndoHelper.UNDO_EDIT_CATEGORY); if (!isEdit) { WindowHelper.Data.SortCategory(); EditorUtility.SetDirty(WindowHelper.Data); AssetDatabase.SaveAssets(); } GUIUtility.keyboardControl = 0; } categoryEdit = isEdit; } EditorGUILayout.EndHorizontal(); GUI.backgroundColor = Color.white; try { for (int i = 0; i < WindowHelper.Data.Category.Count; i++) { var category = WindowHelper.Data.Category[i]; EditorGUILayout.BeginHorizontal(); { category.OnGUI(categoryEdit); if (!category.Name.Equals("default")) { GUI.backgroundColor = Color.red; if (GUILayout.Button("x", new GUILayoutOption[] { GUILayout.Width(20) })) { UndoHelper.EditorMemoUndo(UndoHelper.UNDO_DELETE_CATEGORY); WindowHelper.Data.Category.Remove(category); EditorUtility.SetDirty(WindowHelper.Data); AssetDatabase.SaveAssets(); } GUI.backgroundColor = Color.white; } else { GUILayout.Space(23); } } EditorGUILayout.EndHorizontal(); } } catch { } } EditorGUILayout.EndScrollView(); GUILayout.Space(7); }
public static void OnHierarchyView(int instanceID, Rect selectionRect) { if (Application.isPlaying) { return; } var obj = EditorUtility.InstanceIDToObject(instanceID); if (obj == null) { return; } var localIdentifier = UnitySceneMemoHelper.GetLocalIdentifierInFile(obj); if (localIdentifier == 0) { return; } if (CheckNoGameObjectSelected()) { currentMemo = null; } var gameObject = obj as GameObject; var buttonRect = ButtonRect(selectionRect, gameObject.transform.childCount > 0); var isSelected = CheckSelected(instanceID); var memo = UnitySceneMemoHelper.GetMemo(gameObject, localIdentifier); if (memo == null) { if (isSelected) { if (GUI.Button(buttonRect, "")) { UndoHelper.SceneMemoUndo(UndoHelper.UNDO_SCENEMEMO_ADD); UnitySceneMemoHelper.AddMemo(obj as GameObject, localIdentifier); } GUI.Label(buttonRect, "+"); } } else { GUI.color = GUIHelper.Colors.LabelColor(memo.Label); GUI.DrawTexture(buttonRect, GUIHelper.Textures.Balloon); if (GUI.Button(buttonRect, "", GUIStyle.none)) { UnitySceneMemoHelper.PopupWindowContent.Initialize(memo); PopupWindow.Show(selectionRect, UnitySceneMemoHelper.PopupWindowContent); } GUI.color = Color.white; //if (buttonRect.Contains(Event.current.mousePosition)) //{ // if (Event.current.type == EventType.MouseDown && Event.current.button == 1) // { // GenericMenu menu = new GenericMenu(); // menu.AddItem(new GUIContent("Remove Memo"), false, () => // { // UndoHelper.SceneMemoUndo(UndoHelper.UNDO_SCENEMEMO_DELETE); // UnitySceneMemoHelper.RemoveMemo(memo); // }); // menu.ShowAsContext(); // } //} //SceneView.RepaintAll(); if (isSelected) { currentMemo = memo; } } }
private void OnCategoryOrderChanged(List <UnityEditorMemoCategory> newCategory) { UndoHelper.EditorMemoUndo(UndoHelper.UNDO_EDIT_CATEGORY); WindowHelper.Data.Category = newCategory; }
/// <summary> /// display posting area /// </summary> void PostGUI() { var category = WindowHelper.GetCategory(selectCategoryId); EditorGUILayout.BeginVertical(new GUILayoutOption[] { GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(true) }); { GUILayout.Box("", GUIHelper.Styles.NoSpaceBox, new GUILayoutOption[] { GUILayout.Height(2), GUILayout.ExpandWidth(true) }); EditorGUILayout.BeginHorizontal(EditorStyles.toolbar); { GUILayout.Label(DateTime.Now.RenderDate()); GUILayout.Space(5); GUI.backgroundColor = GUIHelper.Colors.LabelColor(postMemoLabel); postMemoLabel = EditorGUILayout.Popup(postMemoLabel, GUIHelper.LabelMenu, EditorStyles.toolbarPopup, GUILayout.Width(80)); GUI.backgroundColor = Color.white; GUILayout.FlexibleSpace(); GUILayout.Label("URL", GUILayout.Width(30)); postMemoUrl = EditorGUILayout.TextField(postMemoUrl, EditorStyles.toolbarTextField); } EditorGUILayout.EndHorizontal(); if (UnityEditorMemoPrefs.UnityEditorMemoUseSlack) { EditorGUILayout.BeginHorizontal(EditorStyles.toolbar); { UnityEditorMemoPrefs.UnityEditorMemoSlackChannel = EditorGUILayout.TextField(UnityEditorMemoPrefs.UnityEditorMemoSlackChannel); postToSlack = GUILayout.Toggle(postToSlack, "Post to Slack", EditorStyles.toolbarButton, GUILayout.Width(100)); } EditorGUILayout.EndHorizontal(); } GUILayout.Space(5); EditorGUILayout.BeginVertical(); { EditorGUILayout.BeginHorizontal(); { GUILayout.Label((WindowHelper.TEXT_CREATEMEMO_TITLE + category.Name).ToMiddleBold()); GUILayout.FlexibleSpace(); } EditorGUILayout.EndHorizontal(); GUILayout.Space(5); postScrollView = EditorGUILayout.BeginScrollView(postScrollView); { // draft var tmp = EditorGUILayout.TextArea(memoText, GUIHelper.Styles.TextAreaWordWrap, new GUILayoutOption[] { GUILayout.MaxHeight(300) }); if (tmp != memoText) { Undo.IncrementCurrentGroup(); UndoHelper.WindowUndo(UndoHelper.UNDO_DRAFT); memoText = tmp; } } EditorGUILayout.EndScrollView(); EditorGUILayout.BeginHorizontal(); { GUILayout.FlexibleSpace(); postMemoTex = GUILayout.Toolbar(postMemoTex, GUIHelper.Textures.Emotions, new GUILayoutOption[] { GUILayout.Height(30), GUILayout.MaxWidth(150) }); //if ( GUILayout.Button( "test", new GUILayoutOption[] { GUILayout.Height( 30 ), GUILayout.Width( 50 ) } ) ) { // for( int i = 0; i < 110; i++ ) { // category.AddMemo( new UnityEditorMemo( i.ToString(), postMemoLabel, postMemoTex ) ); // } //} // post button GUI.backgroundColor = Color.cyan; if (GUILayout.Button("Post", new GUILayoutOption[] { GUILayout.Height(30), GUILayout.MaxWidth(120) })) { Undo.IncrementCurrentGroup(); UndoHelper.WindowUndo(UndoHelper.UNDO_POST); if (!string.IsNullOrEmpty(memoText)) { var memo = new UnityEditorMemo(memoText, postMemoLabel, postMemoTex, postMemoUrl); memo.id = category.Memo.Count; if (UnityEditorMemoPrefs.UnityEditorMemoUseSlack && postToSlack) { if (SlackHelper.Post(memo, category.Name)) { OnMemoPost(category, memo); } } else { OnMemoPost(category, memo); } } else { Debug.LogWarning(WindowHelper.WARNING_MEMO_EMPTY); } } GUI.backgroundColor = Color.white; } EditorGUILayout.EndHorizontal(); GUILayout.Space(5); } EditorGUILayout.EndVertical(); } EditorGUILayout.EndVertical(); }
private void DrawProcess() { rect = EditorGUILayout.BeginVertical(); { // header GUI.backgroundColor = GUIHelper.Colors.LabelColor(Label); EditorGUILayout.BeginHorizontal(EditorStyles.toolbar); { var edit = GUILayout.Toggle(IsEdit, "≡", EditorStyles.toolbarButton, new GUILayoutOption[] { GUILayout.Width(18) }); if (edit != IsEdit) { GUIUtility.keyboardControl = 0; IsEdit = edit; } EditorGUILayout.BeginHorizontal(); { drawComponents(data.Components); GUILayout.Label(Name); } EditorGUILayout.EndHorizontal(); GUILayout.FlexibleSpace(); } EditorGUILayout.EndHorizontal(); GUI.backgroundColor = Color.white; // memo scrollView = EditorGUILayout.BeginScrollView(scrollView); if (IsEdit) { Undo.IncrementCurrentGroup(); UndoHelper.SceneMemoUndo(UndoHelper.UNDO_SCENEMEMO_EDIT); Memo = EditorGUILayout.TextArea(Memo, GUIHelper.Styles.TextAreaWordWrap, new GUILayoutOption[] { GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true) }); } else { GUILayout.Label(Memo, GUIHelper.Styles.MemoLabel); } EditorGUILayout.EndScrollView(); // footer if (IsEdit) { EditorGUILayout.BeginHorizontal(EditorStyles.toolbar); { GUILayout.FlexibleSpace(); var showAtScene = GUILayout.Toggle(ShowAtScene, "ShowAtScene", EditorStyles.toolbarButton, new GUILayoutOption[] { GUILayout.Width(80) }); if (showAtScene != ShowAtScene) { SceneView.RepaintAll(); ShowAtScene = showAtScene; } GUI.backgroundColor = GUIHelper.Colors.LabelColor(Label); Label = ( UnityEditorMemoLabel )EditorGUILayout.Popup(( int )Label, GUIHelper.LabelMenu, EditorStyles.toolbarDropDown, GUILayout.Width(70)); GUI.backgroundColor = Color.white; } EditorGUILayout.EndHorizontal(); if (ShowAtScene) { GUILayout.Space(3); EditorGUILayout.BeginHorizontal(); { GUILayout.Label("Width"); SceneMemoWidth = EditorGUILayout.Slider(SceneMemoWidth, 200, 500); } EditorGUILayout.EndVertical(); EditorGUILayout.BeginHorizontal(); { GUILayout.Label("Height"); SceneMemoHeight = EditorGUILayout.Slider(SceneMemoHeight, 100, 500); } EditorGUILayout.EndVertical(); EditorGUILayout.BeginHorizontal(); { GUILayout.Label("TextColor"); TextCol = ( UnitySceneMemoTextColor )EditorGUILayout.Popup(( int )TextCol, GUIHelper.TextColorMenu, GUILayout.Width(60)); GUILayout.FlexibleSpace(); } EditorGUILayout.EndVertical(); } GUILayout.Space(5); } } EditorGUILayout.EndVertical(); IsContextClick = eventProcess(Event.current); }
private void MemoGUI(Rect rect) { var emojiRect = this.emojiRect(rect); if (GUIHelper.Textures.Emotions[( int )Tex] != null) { GUI.DrawTexture(emojiRect, GUIHelper.Textures.Emotions[( int )Tex]); } rect.y = emojiRect.y; rect.xMin += emojiRect.xMax + 3f; rect.xMax = rect.xMax - 2f; if (!IsEdit) { rect.height = GUIHelper.Styles.MemoLabel.CalcHeight(new GUIContent(Memo), rowRectWidth - SIZE_EMOJI - 17f); EditorGUI.LabelField(rect, Memo, GUIHelper.Styles.MemoLabel); ObjectReferenceGUI(rect); } else { rect.height = GUIHelper.Styles.TextAreaWordWrap.CalcHeight(new GUIContent(Memo), rowRectWidth - SIZE_EMOJI - 12f); if (preAraHeight != rect.height) { RefreshCustomRowHeights(); preAraHeight = rect.height; } rect.xMax -= 4f; var memo = GUI.TextArea(rect, Memo, GUIHelper.Styles.TextAreaWordWrap); if (memo != Memo) { UndoHelper.EditorMemoUndo(UndoHelper.UNDO_MEMO_EDIT); Memo = memo; } if (ObjectReferenceGUI(rect)) { rect.y += EditorGUIUtility.singleLineHeight; } rect.y += EditorGUIUtility.singleLineHeight + rect.height; rect.height = EditorGUIUtility.singleLineHeight; var url = EditorGUI.TextField(rect, URL); if (url != URL) { UndoHelper.EditorMemoUndo(UndoHelper.UNDO_MEMO_EDIT); URL = url; } var urlLabelRect = rect; urlLabelRect.x -= 32f; EditorGUI.LabelField(urlLabelRect, "URL:"); rect.y += rect.height + EditorGUIUtility.standardVerticalSpacing; rect.height = SIZE_TEX; var tex = ( UnityEditorMemoTexture )GUI.Toolbar(rect, ( int )Tex, GUIHelper.Textures.Emotions); if (tex != Tex) { UndoHelper.EditorMemoUndo(UndoHelper.UNDO_MEMO_EDIT); Tex = tex; } rect.y += rect.height + EditorGUIUtility.standardVerticalSpacing; labelSelectionGUI(rect); } }
public void OnGUI() { rect = EditorGUILayout.BeginVertical(); { // header GUI.backgroundColor = GUIHelper.Colors.LabelColor(Label); var preState = isFold; EditorGUILayout.BeginHorizontal(GUIHelper.Styles.MemoHeader); { GUILayout.Space(5f); GUILayout.Label(Date.ToBold(), new GUILayoutOption[] { GUILayout.ExpandWidth(true), GUILayout.Height(18) }); GUILayout.FlexibleSpace(); var fold = GUILayout.Toggle(isFold, "≡", EditorStyles.toolbarButton, new GUILayoutOption[] { GUILayout.Width(20) }); if (fold != preState) { UndoHelper.EditorMemoUndo(UndoHelper.UNDO_MEMO_EDIT); GUIUtility.keyboardControl = 0; isFold = fold; } } EditorGUILayout.EndHorizontal(); GUI.backgroundColor = Color.white; EditorGUILayout.BeginVertical(GUIHelper.Styles.MemoBack); { GUILayout.Space(2); // memo EditorGUILayout.BeginHorizontal(); { GUILayout.Space(5); EditorGUILayout.BeginVertical(GUILayout.Width(32)); GUILayout.Box(GUIHelper.Textures.Emotions[( int )Tex], GUIStyle.none, new GUILayoutOption[] { GUILayout.Width(32), GUILayout.Height(32) }); EditorGUILayout.EndVertical(); // Display Or Edit Memo if (isFold) { Undo.IncrementCurrentGroup(); UndoHelper.EditorMemoUndo(UndoHelper.UNDO_MEMO_EDIT); Memo = EditorGUILayout.TextArea(Memo, GUIHelper.Styles.TextAreaWordWrap); } else { GUILayout.Label(Memo, GUIHelper.Styles.LabelWordWrap); } } EditorGUILayout.EndHorizontal(); ObjectRef.Draw(isFold); GUILayout.Space(5f); // Display Memo Edit Buttons if (isFold) { EditorGUILayout.BeginHorizontal(); { GUILayout.FlexibleSpace(); Tex = ( UnityEditorMemoTexture )GUILayout.Toolbar(( int )Tex, GUIHelper.Textures.Emotions, new GUILayoutOption[] { GUILayout.Height(25), GUILayout.Width(120) }); Label = ( UnityEditorMemoLabel )EditorGUILayout.Popup(( int )Label, GUIHelper.Label, GUILayout.Width(100)); } EditorGUILayout.EndHorizontal(); GUILayout.Space(5); } } EditorGUILayout.EndVertical(); } EditorGUILayout.EndVertical(); eventProcess(Event.current); }