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 sceneObjectProcess(Object obj)
        {
            var go = obj as GameObject;

            SceneMemo = UnitySceneMemoHelper.GetMemo(go);
            if (SceneMemo != null)
            {
                ScenePath             = go.scene.path;
                LocalIdentifierInFile = SceneMemo.LocalIdentifierInFile;
            }
            Obj = null;
        }
 public void Initialize()
 {
     if (isSceneMemoValid)
     {
         SceneMemo = UnitySceneMemoHelper.GetMemo(ScenePath, LocalIdentifierInFile);
         if (SceneMemo == null)
         {
             ScenePath             = "";
             LocalIdentifierInFile = 0;
         }
     }
 }
        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 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;
                }
            }
        }