private void OnMemoDelete(UnityEditorMemo memo) { UndoHelper.EditorMemoUndo(UndoHelper.UNDO_DELETE_MEMO); WindowHelper.GetCategory(selectCategoryId).Memo.Remove(memo); EditorUtility.SetDirty(WindowHelper.Data); MemoTreeViewInitialize(); }
private void memoPostProcess(UnityEditorMemoCategory category, UnityEditorMemo memo) { category.AddMemo(memo); memoText = ""; postMemoTex = 0; postMemoUrl = ""; memoScrollView = Vector2.zero; if (selectLabel == 0) { postMemoLabel = 0; } GUIUtility.keyboardControl = 0; }
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 static bool Post(UnityEditorMemo memo, string categoryName) { var token = UnityEditorMemoPrefs.UnityEditorMemoSlackAccessToken; var channel = UnityEditorMemoPrefs.UnityEditorMemoSlackChannel; if (string.IsNullOrEmpty(token)) { Debug.LogWarning("UnityEditorMemo: You must set up your access token."); return(false); } if (string.IsNullOrEmpty(channel)) { Debug.LogWarning("UnityEditorMemo: You must set up your access token."); return(false); } var text = memo.Memo; if (!string.IsNullOrEmpty(memo.URL)) { text += string.Format("\n<{0}|URL>", memo.URL); } var titleAttachment = new Attachment { title = string.Format("【{0}】 - {1} {2}\n", PlayerSettings.productName, categoryName, FaceEmoji[( int )memo.Tex]), color = "FFFFFF", }; var memoAttachment = new Attachment { color = ColorUtility.ToHtmlStringRGB(GUIHelper.Colors.LabelColor(memo.Label)), text = text, footer = memo.Date, }; var url = string.Format(APIURL, token, channel, "", JsonUtility.ToJson(titleAttachment), JsonUtility.ToJson(memoAttachment)); var post = postCo(url); while (post.MoveNext()) { } return(( bool )post.Current); }
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(); }
/// <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(); }
public void AddMemo(UnityEditorMemo memo) { Memo.Add(memo); }