Example #1
0
        public BaseGroupElement GetOrCreateGroup(string path)
        {
            if (path == "")
            {
                return(Root);
            }

            s_Separators[0] = config.Separator;
            var parts = path.Split(s_Separators, StringSplitOptions.None);
            BaseGroupElement groupElement = Root;

            string currentPath = "";

            for (int i = 0; i < parts.Length; i++)
            {
                var title = parts[i];
                currentPath += title;

                groupElement.OnBeforeContentNeeded(this);
                bool any = false;
                for (int j = 0; j < groupElement.Children.Count; j++)
                {
                    var child = groupElement.Children[j];
                    if (child.Title == title && child is BaseGroupElement)
                    {
                        groupElement = (BaseGroupElement)child;
                        any          = true;
                        break;
                    }
                }

                if (!any)
                {
                    var g = new GroupElement(title, null);
                    groupElement.Children.Add(g);
                    groupElement = g;
                }

                currentPath += config.Separator;
            }

            return(groupElement);
        }
Example #2
0
        public bool Goto(string path)
        {
            s_Separators[0] = config.Separator;
            var parts = path.Split(s_Separators, StringSplitOptions.None);

            BaseGroupElement groupElement = Root;

            if (groupElement == null)
            {
                Debug.LogError("Not found root");
                return(false);
            }

            string currentPath = "";

            for (int i = 0; i < parts.Length - 1; i++)
            {
                var p = parts[i];
                currentPath += p;

                groupElement.OnBeforeContentNeeded(this);
                bool any = false;
                for (int j = 0; j < groupElement.Children.Count; j++)
                {
                    var child = groupElement.Children[j];
                    if (child.Title == p && child is BaseGroupElement)
                    {
                        groupElement = (BaseGroupElement)child;
                        any          = true;
                        break;
                    }
                }

                if (!any)
                {
                    Debug.LogError("Not found element in path: " + currentPath);
                    return(false);
                }

                currentPath += config.Separator;
            }

//            currentPath += parts[parts.Length - 1];

            bool             anyFound    = false;
            BaseGroupElement gotoElement = groupElement;

            for (int i = 0; i < groupElement.Children.Count; i++)
            {
                var child = groupElement.Children[i];
                if (child.Title == parts[parts.Length - 1])
                {
                    anyFound = true;
                    if (child is BaseGroupElement)
                    {
                        gotoElement = (BaseGroupElement)child;
                    }
                    else
                    {
                        gotoElement.SelectedIndex = i;
                    }
                    break;
                }
            }

            if (anyFound)
            {
                Goto(gotoElement, false);
            }

            return(anyFound);
        }