public static void DrawMemo(UnitySceneMemo memo)
        {
            if (memo == null || !memo.ShowAtScene)
            {
                return;
            }

            Handles.BeginGUI();
            GUILayout.BeginArea(memoRect(memo));
            {
                memo.OnSceneGUI();
            }
            GUILayout.EndArea();
            Handles.EndGUI();
        }
예제 #2
0
        public UnitySceneMemo GetMemo(GameObject obj)
        {
            var            instanceId = obj.GetInstanceID();
            UnitySceneMemo memo       = getMemoFromCache(instanceId);

            if (memo == null)
            {
                var localIdentifierInFile = UnitySceneMemoHelper.GetLocalIdentifierInFile(obj);
                memo = GetMemo(localIdentifierInFile);
                if (memo != null)
                {
                    memo.Initialize(instanceId);
                    CachedMemo.Add(instanceId, memo);
                }
            }
            return(memo);
        }
 private void DrawMemo()
 {
     Memo.OnGUI();
     if (Memo.IsContextClick)
     {
         var menu = new GenericMenu();
         menu.AddItem(new GUIContent("Edit"), false, () => {
             Memo.IsEdit = true;
         });
         menu.AddItem(new GUIContent("Delete"), false, () => {
             UndoHelper.SceneMemoUndo(UndoHelper.UNDO_SCENEMEMO_DELETE);
             SceneMemoHelper.RemoveMemo(Memo);
             Memo = null;
             editorWindow.Close();
         });
         menu.ShowAsContext();
     }
 }
        private static void Draw(UnitySceneMemo memo)
        {
            EditorGUILayout.BeginVertical();
            {
                // header
                GUI.backgroundColor = GUIHelper.Colors.SceneMemoLabelColor(memo.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();
                    {
                        drawComponents(memo.Components);
                        GUILayout.Label(memo.ObjectName);
                    }
                    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.MemoLabel.normal.textColor = GUIHelper.Colors.SceneMemoTextColor(memo.TextCol);
                        GUILayout.Label(memo.Memo, GUIHelper.Styles.MemoLabel);
                        GUIHelper.Styles.MemoLabel.normal.textColor = GUIHelper.Colors.DefaultTextColor;
                    }
                    EditorGUILayout.EndScrollView();
                    GUI.backgroundColor = Color.white;
                }
            }
            EditorGUILayout.EndVertical();
        }
        public void SetReference(Object obj)
        {
            tryFlag = false;

            var path = AssetDatabase.GetAssetPath(obj);

            if (string.IsNullOrEmpty(path))
            {
                var go = obj as GameObject;
                SceneMemo = UnitySceneMemoHelper.GetMemo(go);
                if (SceneMemo != null)
                {
                    ScenePath             = go.scene.path;
                    LocalIdentifierInFile = SceneMemo.LocalIdentifierInFile;
                }
                Obj = null;
            }
            else
            {
                Obj                   = obj;
                ScenePath             = "";
                LocalIdentifierInFile = 0;
            }
        }
 public void Initialize(UnitySceneMemo memo)
 {
     Memo = memo;
     Memo.Initialize(Memo.InstanceId);
     Memo.IsEdit = false;
 }
예제 #7
0
 public void DeleteMemo(UnitySceneMemo memo)
 {
     CachedMemo.Remove(memo.InstanceId);
     Memo.Remove(memo);
 }
예제 #8
0
 public void Initialize(UnitySceneMemo memo)
 {
     this.memo      = memo;
     memoEditorItem = new UnitySceneMemoHierarchyEditorItem(memo);
 }
        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;
                }
            }
        }
예제 #10
0
        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;

                //SceneView.RepaintAll();

                if (isSelected)
                {
                    currentMemo = memo;
                }
            }
        }