Пример #1
0
        static public void AddRawImage(MenuCommand menuCommand)
        {
            GameObject go       = DefaultControls.CreateRawImage(GetStandardResources());
            var        rawImage = go.GetComponent <RawImage>();

            rawImage.raycastTarget = CustomizeUGUICreate.IsRayCastTarget;
            rawImage.material      = CustomizeUGUICreate.GetDefalutMaterial(rawImage.gameObject) ? CustomizeUGUICreate.GetDefalutMaterial(rawImage.gameObject) : rawImage.material;
            PlaceUIElementRoot(go, menuCommand);
        }
Пример #2
0
        static public void AddText(MenuCommand menuCommand)
        {
            GameObject go   = DefaultControls.CreateText(GetStandardResources());
            Text       text = go.GetComponent <Text>();

            text.supportRichText = CustomizeUGUICreate.IsRich;
            text.raycastTarget   = CustomizeUGUICreate.IsRayCastTarget;
            text.material        = CustomizeUGUICreate.GetDefalutMaterial(text.gameObject) ? CustomizeUGUICreate.GetDefalutMaterial(text.gameObject) : text.material;
            PlaceUIElementRoot(go, menuCommand);
        }
Пример #3
0
        static void _setScrollbar(GameObject scrollbar)
        {
            var image = scrollbar.GetComponent <Image>();

            image.sprite   = CustomizeUGUICreate.GetDefalutSprite(image.gameObject) ? CustomizeUGUICreate.GetDefalutSprite(image.gameObject) : image.sprite;
            image.material = CustomizeUGUICreate.GetDefalutMaterial(image.gameObject) ? CustomizeUGUICreate.GetDefalutMaterial(image.gameObject) : image.material;

            var Handle = scrollbar.transform.Find("Sliding Area").GetChild(0).GetComponent <Image>();

            Handle.sprite   = CustomizeUGUICreate.GetDefalutSprite(Handle.gameObject) ? CustomizeUGUICreate.GetDefalutSprite(Handle.gameObject) : Handle.sprite;
            Handle.material = CustomizeUGUICreate.GetDefalutMaterial(Handle.gameObject)? CustomizeUGUICreate.GetDefalutMaterial(Handle.gameObject) : Handle.material;
        }
Пример #4
0
        static public void AddScrollView(MenuCommand menuCommand)
        {
            GameObject go = DefaultControls.CreateScrollView(GetStandardResources());

            PlaceUIElementRoot(go, menuCommand);

            var viewport = go.transform.Find("Viewport").gameObject;

            if (CustomizeUGUICreate.NoToRectMask)
            {
                var viewportImage = viewport.GetComponent <Image>();

                Sprite sprite = CustomizeUGUICreate.GetDefalutSprite(viewport);

                if (!sprite)
                {
                    sprite = viewportImage.sprite;
                }

                viewportImage.sprite        = sprite;
                viewportImage.raycastTarget = CustomizeUGUICreate.IsRayCastTarget;

                Material material = CustomizeUGUICreate.GetDefalutMaterial(viewport.gameObject);

                if (!material)
                {
                    material = viewportImage.material;
                }

                viewportImage.material = material;
            }
            else
            {
                Object.DestroyImmediate(viewport.GetComponent <Image>());
                Object.DestroyImmediate(viewport.GetComponent <Mask>());
                viewport.AddComponent <RectMask2D>();
            }


            var goImage = go.GetComponent <Image>();

            goImage.sprite   = CustomizeUGUICreate.GetDefalutSprite(goImage.gameObject) ? CustomizeUGUICreate.GetDefalutSprite(goImage.gameObject) : goImage.sprite;
            goImage.material = CustomizeUGUICreate.GetDefalutMaterial(goImage.gameObject) ? CustomizeUGUICreate.GetDefalutMaterial(goImage.gameObject) : goImage.material;

            var Scrollbar_Horizontal = go.transform.Find("Scrollbar Horizontal").gameObject;
            var Scrollbar_Vertical   = go.transform.Find("Scrollbar Vertical").gameObject;

            _setScrollbar(Scrollbar_Horizontal);
            _setScrollbar(Scrollbar_Vertical);
        }
Пример #5
0
        static public void AddDropdown(MenuCommand menuCommand)
        {
            GameObject go = DefaultControls.CreateDropdown(GetStandardResources());

            PlaceUIElementRoot(go, menuCommand);

            var Label           = go.transform.Find("Label").GetComponent <Text>();
            var Arrow           = go.transform.Find("Arrow").GetComponent <Image>();
            var Template        = go.transform.Find("Template").GetComponent <Image>();
            var Viewport        = Template.transform.Find("Viewport").GetComponent <Image>();
            var Item            = Viewport.transform.Find("Content").transform.Find("Item").GetComponent <Toggle>();
            var Item_Background = Item.transform.Find("Item Background").GetComponent <Image>();
            var Item_Checkmark  = Item.transform.Find("Item Checkmark").GetComponent <Image>();
            var Item_Label      = Item.transform.Find("Item Label").GetComponent <Text>();

            Label.raycastTarget   = CustomizeUGUICreate.IsRayCastTarget;
            Label.supportRichText = CustomizeUGUICreate.IsRich;
            Label.material        = CustomizeUGUICreate.GetDefalutMaterial(Item_Label.gameObject) ? CustomizeUGUICreate.GetDefalutMaterial(Item_Label.gameObject) : Label.material;

            Item_Label.material        = CustomizeUGUICreate.GetDefalutMaterial(Item_Label.gameObject) ? CustomizeUGUICreate.GetDefalutMaterial(Item_Label.gameObject) : Item_Label.material;
            Item_Label.supportRichText = CustomizeUGUICreate.IsRich;

            Arrow.sprite        = CustomizeUGUICreate.GetDefalutSprite(Arrow.gameObject) ? CustomizeUGUICreate.GetDefalutSprite(Arrow.gameObject) : Arrow.sprite;
            Arrow.raycastTarget = CustomizeUGUICreate.IsRayCastTarget;
            Arrow.material      = CustomizeUGUICreate.GetDefalutMaterial(Arrow.gameObject) ? CustomizeUGUICreate.GetDefalutMaterial(Arrow.gameObject) : Arrow.material;

            Template.sprite        = CustomizeUGUICreate.GetDefalutSprite(Template.gameObject) ? CustomizeUGUICreate.GetDefalutSprite(Template.gameObject) : Arrow.sprite;
            Template.raycastTarget = CustomizeUGUICreate.IsRayCastTarget;
            Template.material      = CustomizeUGUICreate.GetDefalutMaterial(Template.gameObject) ? CustomizeUGUICreate.GetDefalutMaterial(Template.gameObject) : Template.material;

            Viewport.sprite        = CustomizeUGUICreate.GetDefalutSprite(Viewport.gameObject) ? CustomizeUGUICreate.GetDefalutSprite(Viewport.gameObject) : Viewport.sprite;
            Viewport.raycastTarget = CustomizeUGUICreate.IsRayCastTarget;
            Viewport.material      = CustomizeUGUICreate.GetDefalutMaterial(Viewport.gameObject) ? CustomizeUGUICreate.GetDefalutMaterial(Viewport.gameObject) : Viewport.material;

            Item_Background.sprite        = CustomizeUGUICreate.GetDefalutSprite(Item_Background.gameObject) ? CustomizeUGUICreate.GetDefalutSprite(Item_Background.gameObject) : Item_Background.sprite;
            Item_Background.raycastTarget = CustomizeUGUICreate.IsRayCastTarget;
            Item_Background.material      = CustomizeUGUICreate.GetDefalutMaterial(Item_Background.gameObject) ? CustomizeUGUICreate.GetDefalutMaterial(Item_Background.gameObject) : Item_Background.material;

            Item_Checkmark.sprite        = CustomizeUGUICreate.GetDefalutSprite(Item_Checkmark.gameObject) ? CustomizeUGUICreate.GetDefalutSprite(Item_Checkmark.gameObject) : Item_Checkmark.sprite;
            Item_Checkmark.raycastTarget = CustomizeUGUICreate.IsRayCastTarget;
            Item_Checkmark.material      = CustomizeUGUICreate.GetDefalutMaterial(Item_Checkmark.gameObject) ? CustomizeUGUICreate.GetDefalutMaterial(Item_Checkmark.gameObject) : Item_Checkmark.material;

            var goImage = go.GetComponent <Image>();

            goImage.sprite = CustomizeUGUICreate.GetDefalutSprite(goImage.gameObject) ? CustomizeUGUICreate.GetDefalutSprite(goImage.gameObject) : goImage.sprite;

            goImage.material = CustomizeUGUICreate.GetDefalutMaterial(goImage.gameObject) ? CustomizeUGUICreate.GetDefalutMaterial(goImage.gameObject) : goImage.material;
        }
Пример #6
0
        static public void AddButton(MenuCommand menuCommand)
        {
            GameObject go = DefaultControls.CreateButton(GetStandardResources());

            var image = go.GetComponent <Image>();

            image.sprite   = CustomizeUGUICreate.GetDefalutSprite(image.gameObject) ? CustomizeUGUICreate.GetDefalutSprite(image.gameObject) : image.sprite;
            image.material = CustomizeUGUICreate.GetDefalutMaterial(image.gameObject) ? CustomizeUGUICreate.GetDefalutMaterial(image.gameObject) : image.material;

            var text = go.transform.GetChild(0).GetComponent <Text>();

            text.supportRichText = CustomizeUGUICreate.IsRich;
            text.raycastTarget   = CustomizeUGUICreate.IsRayCastTarget;
            text.material        = CustomizeUGUICreate.GetDefalutMaterial(text.gameObject) ? CustomizeUGUICreate.GetDefalutMaterial(text.gameObject) : text.material;

            PlaceUIElementRoot(go, menuCommand);
        }
Пример #7
0
        static public void AddPanel(MenuCommand menuCommand)
        {
            GameObject go = DefaultControls.CreatePanel(GetStandardResources());

            PlaceUIElementRoot(go, menuCommand);

            var image = go.GetComponent <Image>();

            image.sprite        = CustomizeUGUICreate.GetDefalutSprite(image.gameObject) ? CustomizeUGUICreate.GetDefalutSprite(image.gameObject) : image.sprite;
            image.raycastTarget = CustomizeUGUICreate.IsRayCastTarget;
            image.material      = CustomizeUGUICreate.GetDefalutMaterial(image.gameObject) ? CustomizeUGUICreate.GetDefalutMaterial(image.gameObject) : image.material;

            // Panel is special, we need to ensure there's no padding after repositioning.
            RectTransform rect = go.GetComponent <RectTransform>();

            rect.anchoredPosition = Vector2.zero;
            rect.sizeDelta        = Vector2.zero;
        }
Пример #8
0
        static public void AddSlider(MenuCommand menuCommand)
        {
            GameObject go         = DefaultControls.CreateSlider(GetStandardResources());
            var        Background = go.transform.Find("Background").GetComponent <Image>();
            var        Fill       = go.transform.Find("Fill Area").GetChild(0).GetComponent <Image>();
            var        Handle     = go.transform.Find("Handle Slide Area").GetChild(0).GetComponent <Image>();

            Background.sprite        = CustomizeUGUICreate.GetDefalutSprite(Background.gameObject) ? CustomizeUGUICreate.GetDefalutSprite(Background.gameObject) : Background.sprite;
            Background.material      = CustomizeUGUICreate.GetDefalutMaterial(Background.gameObject) ? CustomizeUGUICreate.GetDefalutMaterial(Background.gameObject) : Background.material;
            Background.raycastTarget = CustomizeUGUICreate.IsRayCastTarget;

            Fill.sprite        = CustomizeUGUICreate.GetDefalutSprite(Fill.gameObject) ? CustomizeUGUICreate.GetDefalutSprite(Fill.gameObject) : Fill.sprite;
            Fill.raycastTarget = CustomizeUGUICreate.IsRayCastTarget;
            Fill.material      = CustomizeUGUICreate.GetDefalutMaterial(Fill.gameObject) ? CustomizeUGUICreate.GetDefalutMaterial(Fill.gameObject) : Fill.material;

            Handle.sprite   = CustomizeUGUICreate.GetDefalutSprite(Handle.gameObject) ? CustomizeUGUICreate.GetDefalutSprite(Handle.gameObject) : Handle.sprite;
            Handle.material = CustomizeUGUICreate.GetDefalutMaterial(Handle.gameObject) ? CustomizeUGUICreate.GetDefalutMaterial(Handle.gameObject) : Handle.material;

            PlaceUIElementRoot(go, menuCommand);
        }
Пример #9
0
        static public void AddToggle(MenuCommand menuCommand)
        {
            GameObject go = DefaultControls.CreateToggle(GetStandardResources());

            var background = go.transform.Find("Background").GetComponent <Image>();

            background.sprite   = CustomizeUGUICreate.GetDefalutSprite(background.gameObject) ? CustomizeUGUICreate.GetDefalutSprite(background.gameObject) : background.sprite;
            background.material = CustomizeUGUICreate.GetDefalutMaterial(background.gameObject) ? CustomizeUGUICreate.GetDefalutMaterial(background.gameObject) : background.material;

            var checkmark = background.transform.Find("Checkmark").GetComponent <Image>();

            checkmark.sprite        = CustomizeUGUICreate.GetDefalutSprite(checkmark.gameObject) ? CustomizeUGUICreate.GetDefalutSprite(checkmark.gameObject) : checkmark.sprite;
            checkmark.raycastTarget = CustomizeUGUICreate.IsRayCastTarget;
            checkmark.material      = CustomizeUGUICreate.GetDefalutMaterial(checkmark.gameObject)? CustomizeUGUICreate.GetDefalutMaterial(checkmark.gameObject) : checkmark.material;

            var lable = go.transform.Find("Label").GetComponent <Text>();

            lable.supportRichText = CustomizeUGUICreate.IsRich;
            lable.material        = CustomizeUGUICreate.GetDefalutMaterial(lable.gameObject) ? CustomizeUGUICreate.GetDefalutMaterial(lable.gameObject) : lable.material;

            PlaceUIElementRoot(go, menuCommand);
        }
Пример #10
0
        public static void AddInputField(MenuCommand menuCommand)
        {
            GameObject go = DefaultControls.CreateInputField(GetStandardResources());

            PlaceUIElementRoot(go, menuCommand);

            var Placeholder = go.transform.Find("Placeholder").GetComponent <Text>();

            Placeholder.supportRichText = CustomizeUGUICreate.IsRich;
            Placeholder.raycastTarget   = CustomizeUGUICreate.IsRayCastTarget;
            Placeholder.material        = CustomizeUGUICreate.GetDefalutMaterial(Placeholder.gameObject) ? CustomizeUGUICreate.GetDefalutMaterial(Placeholder.gameObject) : Placeholder.material;

            var Text = go.transform.Find("Text").GetComponent <Text>();

            Text.supportRichText = CustomizeUGUICreate.IsRich;
            Text.raycastTarget   = CustomizeUGUICreate.IsRayCastTarget;
            Text.material        = CustomizeUGUICreate.GetDefalutMaterial(Text.gameObject) ? CustomizeUGUICreate.GetDefalutMaterial(Text.gameObject): Text.material;

            var goImage = go.GetComponent <Image>();

            goImage.sprite = CustomizeUGUICreate.GetDefalutSprite(goImage.gameObject) ? CustomizeUGUICreate.GetDefalutSprite(goImage.gameObject) : goImage.sprite;

            goImage.material = CustomizeUGUICreate.GetDefalutMaterial(goImage.gameObject)? CustomizeUGUICreate.GetDefalutMaterial(goImage.gameObject) : goImage.material;
        }