Beispiel #1
0
        private void AddBookmark(Object obj)
        {
            ObjectBookmark newBookmark = GetBookmark(obj);

            if (newBookmark != null)
            {
                m_Bookmarks.Add(newBookmark);
                SaveProfile();
            }
        }
        private void OnDrawElement(Rect rect, int index, bool isActive, bool isFocused) {
            ObjectBookmark bookmark = m_Bookmarks[index];
            if (bookmark.OnGUI(rect)) {
                m_DeleteMe = bookmark;
            }

            if (bookmark.NewObject) {
                m_Bookmarks[index] = GetBookmark(bookmark.NewObject);
                SaveProfile();
            }
        }
        private void LoadProfile() {
            // Debug.Log("ObjectBookmarks: Loading.", this);
            m_ScrollPosition = new Vector2(0.0f, 0.0f);
            m_Bookmarks = new List<ObjectBookmark>();
            m_BookmarksGUI = new ReorderableList(m_Bookmarks, typeof(ObjectBookmark), true, false, false, false) {headerHeight = 0, footerHeight = 0};
            m_BookmarksGUI.drawElementCallback += OnDrawElement;
            m_BookmarksGUI.onChangedCallback += OnListChanged;
            m_BookmarksGUI.drawFooterCallback += OnDrawFooter;

            int itemCount = 0;

            if (EditorPrefs.HasKey(s_KeyItemCount)) {
                itemCount = EditorPrefs.GetInt(s_KeyItemCount);
            }

            for (int i = 0; i < itemCount; ++i) {
                ObjectBookmark newBookmark = GetSavedBookmark(i);

                if (newBookmark != null) {
                    m_Bookmarks.Add(newBookmark);
                }
            }
        }