Exemplo n.º 1
0
        public void SetRoot(UIRoot root)
        {
            widgets.RemoveAll();

            if (root == null)
            {
                return;
            }

            Transform[] all = root.transform.GetComponentsInChildren <Transform>(true);
            foreach (Transform t in all)
            {
                GameObject o = t.gameObject;
                if (o.GetComponent <UILabel>() != null)
                {
                    widgets.Add(WidgetType.Label, o);
                }
                else if (o.GetComponent <UIButton>() != null || o.GetComponent <UIImageButton>() != null)
                {
                    widgets.Add(WidgetType.Button, o);
                }
                else if (o.GetComponent <UIToggle>() != null)
                {
                    widgets.Add(WidgetType.Button, o);
                }
                else if (o.GetComponent <UISlider>() != null)
                {
                    if (o.GetComponentInChildren <UIButtonColor>() != null)
                    {
                        widgets.Add(WidgetType.Slider, o);
                    }
                    else
                    {
                        widgets.Add(WidgetType.ProgressBar, o);
                    }
                }
                else if (o.GetComponent <UIInput>() != null)
                {
                    widgets.Add(WidgetType.Input, o);
                }
                else if (o.GetComponent <UIPopupList>() != null)
                {
                    widgets.Add(WidgetType.PopupList, o);
                }
                else if (o.GetComponent <UISprite>() != null)
                {
                    widgets.Add(WidgetType.Texture, o);
                }
                else if (o.GetComponent <UIScrollBar>() != null)
                {
                }
            }
            // remove unnecessary widgets
            RemoveLabels(WidgetType.Button);
            RemoveLabels(WidgetType.Checkbox);
            RemoveLabels(WidgetType.Input);
            RemoveLabels(WidgetType.PopupList);

            RemoveTextures(WidgetType.Button);
            RemoveTextures(WidgetType.Slider);
            RemoveTextures(WidgetType.ProgressBar);
        }