Example #1
0
        public override GameObject CreateInstence(WidgetItem info)
        {
            var ok = EditorApplication.ExecuteMenuItem("GameObject/UI/Image");

            if (ok)
            {
                var backgroundImage = Selection.activeGameObject;
                if (info.spriteDic.ContainsKey(KeyWord.background))
                {
                    WidgetUtility.InitImage(backgroundImage.GetComponent <Image>(), info.spriteDic[KeyWord.background]);
                }
                ok = EditorApplication.ExecuteMenuItem("GameObject/UI/Image");
                if (ok)
                {
                    var fillImage = Selection.activeGameObject.GetComponent <Image>();
                    fillImage.name = KeyWord.fill;

                    fillImage.type       = Image.Type.Filled;
                    fillImage.fillMethod = Image.FillMethod.Radial360;
                    if (info.spriteDic.ContainsKey(KeyWord.fill))
                    {
                        fillImage.sprite = info.spriteDic[KeyWord.fill];
                    }

                    fillImage.transform.SetParent(backgroundImage.transform, false);
                    (fillImage.transform as RectTransform).anchorMin = Vector2.zero;
                    (fillImage.transform as RectTransform).anchorMax = Vector2.one;
                    fillImage.transform.localPosition = Vector3.zero;
                    (fillImage.transform as RectTransform).SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, (backgroundImage.transform as RectTransform).sizeDelta.x);
                    (fillImage.transform as RectTransform).SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, (backgroundImage.transform as RectTransform).sizeDelta.y);
                }
                return(backgroundImage);
            }
            return(null);
        }
        protected override void ChargeWidgetInfo(Component component, WidgetItem info)
        {
            Dropdown dropdown = component as Dropdown;
            var      dic      = info.spriteDic;

            if (dic.ContainsKey(backgroundbase))
            {
                WidgetUtility.InitImage(dropdown.targetGraphic as Image, dic[backgroundbase], Image.Type.Sliced);
            }

            if (dic.ContainsKey(backgroundgroup))
            {
                dropdown.template.GetComponent <Image>().sprite = dic[backgroundgroup];
            }

            if (dic.ContainsKey(backgrounditem))
            {
                var itemgraph = dropdown.template.GetComponentInChildren <Toggle>().targetGraphic as Image;
                itemgraph.sprite = dic[backgrounditem];
            }

            var scrollbar = dropdown.template.GetComponentInChildren <Scrollbar>();

            if (dic.ContainsKey(scrollbarbackground))
            {
                (scrollbar.targetGraphic as Image).sprite = dic[scrollbarbackground];
            }
            if (dic.ContainsKey(scrollbarfill))
            {
                scrollbar.handleRect.GetComponent <Image>().sprite = dic[scrollbarfill];
            }
        }
Example #3
0
        protected override void ChargeWidgetInfo(Component component, WidgetItem info)
        {
            var image = component as Image;

            if (info.spriteDic.ContainsKey(KeyWord.sprite))
            {
                WidgetUtility.InitImage(image, info.spriteDic[KeyWord.sprite], Image.Type.Simple);
            }
        }
Example #4
0
        protected override void ChargeWidgetInfo(Component component, WidgetItem info)
        {
            var inputfield = component as  InputField;

            if (info.spriteDic.ContainsKey(KeyWord.background))
            {
                var image = inputfield.targetGraphic as Image;
                WidgetUtility.InitImage(image, info.spriteDic[KeyWord.background]);
            }
        }
Example #5
0
        public override GameObject CreateInstence(WidgetItem info)
        {
            var ok = EditorApplication.ExecuteMenuItem("GameObject/UI/Image");

            if (ok)
            {
                var created = Selection.activeGameObject;
                var image   = Selection.activeGameObject.GetComponent <Image>();
                if (info.spriteDic.ContainsKey(KeyWord.sprite))
                {
                    WidgetUtility.InitImage(image, info.spriteDic[KeyWord.sprite], Image.Type.Simple);
                }
                return(created);
            }
            return(null);
        }
Example #6
0
        public override GameObject CreateInstence(WidgetItem info)
        {
            var ok = EditorApplication.ExecuteMenuItem("GameObject/UI/Input Field");

            if (ok)
            {
                var inputfield = Selection.activeGameObject.GetComponent <InputField>();
                if (info.spriteDic.ContainsKey(KeyWord.background))
                {
                    var image = inputfield.targetGraphic as Image;
                    WidgetUtility.InitImage(image, info.spriteDic[KeyWord.background]);
                }

                return(inputfield.gameObject);
            }
            return(null);
        }
        public override GameObject CreateInstence(WidgetItem info)
        {
            var ok = EditorApplication.ExecuteMenuItem("GameObject/UI/Dropdown");

            if (ok)
            {
                Dropdown dropdown = Selection.activeGameObject.GetComponent <Dropdown>();
                var      dic      = info.spriteDic;
                if (dic.ContainsKey(backgroundbase))
                {
                    WidgetUtility.InitImage(dropdown.targetGraphic as Image, dic[backgroundbase], Image.Type.Sliced);
                }

                if (dic.ContainsKey(backgroundgroup))
                {
                    dropdown.template.GetComponent <Image>().sprite = dic[backgroundgroup];
                }

                if (dic.ContainsKey(backgrounditem))
                {
                    var itemgraph = dropdown.template.GetComponentInChildren <Toggle>().targetGraphic as Image;
                    itemgraph.sprite = dic[backgrounditem];
                }

                var scrollbar = dropdown.template.GetComponentInChildren <Scrollbar>();

                if (dic.ContainsKey(scrollbarbackground))
                {
                    (scrollbar.targetGraphic as Image).sprite = dic[scrollbarbackground];
                }
                if (dic.ContainsKey(scrollbarfill))
                {
                    scrollbar.handleRect.GetComponent <Image>().sprite = dic[scrollbarfill];
                }
                return(dropdown.gameObject);
            }
            return(null);
        }