Exemplo n.º 1
0
        public DebugMenu()
        {
            rootItem      = new DebugGroup("Debug");
            rootItem.Menu = this;
            curItem       = rootItem;

            Style = new DebugStyle();
        }
        /// <summary>
        /// Remove debug items by the specified name.
        /// </summary>
        /// <param name="name">Name of item to be deleted. Name can be a single name or path separated by dot (.).</param>
        public override void Remove(string name)
        {
            string deletedName = name;
            int    index       = name.IndexOf('.');

            if (index >= 0)
            {
                deletedName = name.Substring(0, index);

                IDebugGroup group = (IDebugGroup)items.Find(item => item.Name.Equals(deletedName));
                if (group != null)
                {
                    group.Remove(name.Substring(index + 1));
                }
            }
            else
            {
                items.RemoveAll(item => item.Name == deletedName);
            }
        }
        /// <summary>
        /// Draws the item list.
        /// </summary>
        protected override void DrawContent()
        {
            GUILayout.BeginVertical(lowOpacity ? Menu.Style.LowOpacityBoxStyle : Menu.Style.BoxStyle);

            GUILayout.Label(Content);

            GUILayout.BeginHorizontal();

            // TODO: Draw button back
            if (GUILayout.Button(LABEL_BACK))
            {
                Back();
            }

            // TODO: Draw button close
            if (GUILayout.Button(LABEL_CLOSE))
            {
                Close();
            }

            GUILayout.EndHorizontal();

            if (scrollStyle == null)
            {
                scrollStyle = new GUIStyle(GUI.skin.scrollView);

                // Set padding right for 20 px to avoid overlapping
                // the right scrollbar over the elements
                scrollStyle.padding.right = 20;
            }

            if (items.Count > 2)
            {
                scrollPos = GUILayout.BeginScrollView(scrollPos, scrollStyle,
                                                      GUILayout.Height(Mathf.Clamp(items.Count, 0, MAX_DISPLAY_COUNT) * MAX_ELEMENT_HEIGHT));
            }

            // Draw to list all debug items
            for (int i = 0; i < items.Count; i++)
            {
                IDebugItem item = items [i];
                item.Draw();
                if (item is IDebugGroup)
                {
                    IDebugGroup group = (IDebugGroup)item;
                    if (group.IsAccess)
                    {
                        InvokeOnExit();
                        Menu.CurrentItem = group;
                        break;
                    }
                }
            }

            if (items.Count > 2)
            {
                GUILayout.EndScrollView();
            }

            GUILayout.EndVertical();
        }
Exemplo n.º 4
0
        public void Close()
        {
            IDebugGroup group = curItem;

            group.Close();
        }