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();
            }
        }
        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);
        }
        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();
        }
Beispiel #5
0
        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);
        }
        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;
                }
            }
        }