//=======================================================
        // 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);
        }
        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;
            }
        }
Beispiel #3
0
        //======================================================================
        // 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;
                }
            }
        }
Beispiel #4
0
        private void OnCategoryDelete(UnityEditorMemoCategory category)
        {
            UndoHelper.EditorMemoUndo(UndoHelper.UNDO_DELETE_CATEGORY);

            WindowHelper.Data.Category.Remove(category);
            CategoryTreeViewInitialize();
            MemoTreeViewInitialize();
        }
Beispiel #5
0
        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();
        }
Beispiel #7
0
        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();
        }
Beispiel #9
0
        private void OnCategoryCreate()
        {
            UndoHelper.EditorMemoUndo(UndoHelper.UNDO_CREATE_CATEGORY);

            var newCategory = new UnityEditorMemoCategory("new Category");

            WindowHelper.Data.AddCategory(newCategory);
            CategoryTreeViewInitialize();
            categoryTreeView.BeginRename(newCategory);
        }
        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);
            }
        }
Beispiel #11
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 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();
     }
 }
Beispiel #13
0
        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;
        }
        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);
        }
Beispiel #16
0
        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();
        }
Beispiel #17
0
        /// <summary>
        /// display posting area
        /// </summary>
        void PostContents()
        {
            var category = WindowHelper.CurCategory(selectCategoryId);

            EditorGUILayout.BeginVertical(new GUILayoutOption[] { GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(true) });
            {
                GUILayout.Box("", GUIHelper.Styles.NoSpaceBox, new GUILayoutOption[] { GUILayout.Height(2), GUILayout.ExpandWidth(true) });
                GUILayout.Space(5);
                GUILayout.Label((WindowHelper.TEXT_CREATEMEMO_TITLE + category.Name).ToMiddleBold());
                EditorGUILayout.BeginVertical();
                {
                    // date
                    EditorGUILayout.BeginHorizontal();
                    {
                        GUILayout.Label(DateTime.Now.RenderDate(), GUIHelper.Styles.MemoBox, new GUILayoutOption[] { GUILayout.Width(150), GUILayout.Height(25) });
                        postMemoLabel = EditorGUILayout.Popup(postMemoLabel, GUIHelper.Label, GUILayout.Width(100));
                    }
                    EditorGUILayout.EndHorizontal();

                    GUILayout.Space(5);

                    // draft
                    Undo.IncrementCurrentGroup();
                    UndoHelper.WindowUndo(UndoHelper.UNDO_DRAFT);
                    memoText = EditorGUILayout.TextArea(memoText, GUIHelper.Styles.TextAreaWordWrap, new GUILayoutOption[] { GUILayout.MaxHeight(300) });
                    EditorGUILayout.BeginHorizontal();
                    {
                        postMemoTex = GUILayout.Toolbar(postMemoTex, GUIHelper.Textures.Emotions, new GUILayoutOption[] { GUILayout.Height(30), GUILayout.Width(150) });
                        GUILayout.FlexibleSpace();

                        //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.Width(100) }))
                        {
                            if (!string.IsNullOrEmpty(memoText))
                            {
                                Undo.IncrementCurrentGroup();
                                UndoHelper.EditorMemoUndo(UndoHelper.UNDO_POST);

                                category.AddMemo(new UnityEditorMemo(memoText, postMemoLabel, postMemoTex));
                                memoText                   = "";
                                postMemoLabel              = 0;
                                postMemoTex                = 0;
                                memoScrollView             = Vector2.zero;
                                GUIUtility.keyboardControl = 0;
                            }
                            else
                            {
                                Debug.LogWarning(WindowHelper.WARNING_MEMO_EMPTY);
                            }
                        }
                        GUI.backgroundColor = Color.white;
                    }
                    EditorGUILayout.EndHorizontal();

                    GUILayout.Space(5);
                }
                EditorGUILayout.EndVertical();
            }
            EditorGUILayout.EndVertical();
        }
Beispiel #18
0
        /// <summary>
        /// display posting area
        /// </summary>
        void PostContents()
        {
            var category = WindowHelper.CurCategory(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());
                    GUI.backgroundColor = GUIHelper.Colors.LabelColor(postMemoLabel);
                    postMemoLabel       = EditorGUILayout.Popup(postMemoLabel, GUIHelper.LabelMenu, EditorStyles.toolbarPopup, GUILayout.Width(100));
                    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);

                    // draft
                    Undo.IncrementCurrentGroup();
                    UndoHelper.WindowUndo(UndoHelper.UNDO_DRAFT);

                    postScrollView = EditorGUILayout.BeginScrollView(postScrollView);
                    {
                        memoText = EditorGUILayout.TextArea(memoText, GUIHelper.Styles.TextAreaWordWrap, new GUILayoutOption[] { GUILayout.MaxHeight(300) });
                    }
                    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);
                            UndoHelper.EditorMemoUndo(UndoHelper.UNDO_POST);
                            if (!string.IsNullOrEmpty(memoText))
                            {
                                var memo = new UnityEditorMemo(memoText, postMemoLabel, postMemoTex, postMemoUrl);
                                if (UnityEditorMemoPrefs.UnityEditorMemoUseSlack && postToSlack)
                                {
                                    if (SlackHelper.Post(memo, category.Name))
                                    {
                                        memoPostProcess(category, memo);
                                    }
                                }
                                else
                                {
                                    memoPostProcess(category, memo);
                                }
                            }
                            else
                            {
                                Debug.LogWarning(WindowHelper.WARNING_MEMO_EMPTY);
                            }
                        }
                        GUI.backgroundColor = Color.white;
                    }
                    EditorGUILayout.EndHorizontal();

                    GUILayout.Space(5);
                }
                EditorGUILayout.EndVertical();
            }
            EditorGUILayout.EndVertical();
        }
Beispiel #19
0
        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);
        }
Beispiel #20
0
        public void OnGUI()
        {
            rect = EditorGUILayout.BeginVertical();
            {
                // header
                GUI.backgroundColor = GUIHelper.Colors.LabelColor(Label);
                var preState = isFoldout;
                EditorGUILayout.BeginHorizontal(GUIHelper.Styles.MemoHeader);
                {
                    var fold = GUILayout.Toggle(isFoldout, "≡", EditorStyles.toolbarButton, new GUILayoutOption[] { GUILayout.Width(20) });
                    if (fold != preState)
                    {
                        UndoHelper.EditorMemoUndo(UndoHelper.UNDO_MEMO_EDIT);
                        GUIUtility.keyboardControl = 0;
                        isFoldout = fold;
                    }

                    GUILayout.Label(Date.ToBold(), new GUILayoutOption[] { GUILayout.ExpandWidth(true), GUILayout.Height(18) });

                    GUILayout.FlexibleSpace();

                    if (!string.IsNullOrEmpty(URL))
                    {
                        if (GUILayout.Button(new GUIContent("open", GUIHelper.Textures.OpenLink), EditorStyles.toolbarButton, new GUILayoutOption[] { GUILayout.Width(60) }))
                        {
                            Application.OpenURL(URL);
                        }
                    }
                }
                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 (isFoldout)
                        {
                            Undo.IncrementCurrentGroup();
                            UndoHelper.EditorMemoUndo(UndoHelper.UNDO_MEMO_EDIT);
                            Memo = EditorGUILayout.TextArea(Memo, GUIHelper.Styles.TextAreaWordWrap);
                        }
                        else
                        {
                            GUIHelper.Styles.LabelWordWrap.fontSize = UnityEditorMemoPrefs.UnityEditorMemoFontSize;
                            GUILayout.Label(Memo, GUIHelper.Styles.LabelWordWrap);
                        }
                    }
                    EditorGUILayout.EndHorizontal();

                    ObjectRef.Draw(isFoldout);

                    GUILayout.Space(5);

                    // edit memo menu
                    if (isFoldout)
                    {
                        EditorGUILayout.BeginHorizontal();
                        {
                            GUILayout.Space(37);

                            GUILayout.Label("URL", GUILayout.Width(30));
                            URL = EditorGUILayout.TextField(URL, GUIHelper.Styles.TextFieldWordWrap);

                            Tex   = ( UnityEditorMemoTexture )GUILayout.Toolbar(( int )Tex, GUIHelper.Textures.Emotions, new GUILayoutOption[] { GUILayout.Height(23), GUILayout.Width(110) });
                            Label = ( UnityEditorMemoLabel )EditorGUILayout.Popup(( int )Label, GUIHelper.LabelMenu, GUIHelper.Styles.LargeDropdown, GUILayout.Width(90));
                        }
                        EditorGUILayout.EndHorizontal();
                        GUILayout.Space(5);
                    }
                }
                EditorGUILayout.EndVertical();
            }
            EditorGUILayout.EndVertical();

            eventProcess(Event.current);
        }
Beispiel #21
0
        private void OnCategoryOrderChanged(List <UnityEditorMemoCategory> newCategory)
        {
            UndoHelper.EditorMemoUndo(UndoHelper.UNDO_EDIT_CATEGORY);

            WindowHelper.Data.Category = newCategory;
        }
        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);
            }
        }