Ejemplo n.º 1
0
        static GameObject CreateRawImageEx(UIResources resources)
        {
            GameObject rawImage = DefaultControls.CreateRawImage(UIDefaultControls.ConvertToDefaultResources(resources));

            rawImage.name = "RawImageEx";
            rawImage.AddComponent <UIDragable>();
            rawImage.AddComponent <ColorGradient>();
            return(rawImage);
        }
Ejemplo n.º 2
0
        static GameObject CreateButtonEx(UIResources resources)
        {
            GameObject button = DefaultControls.CreateButton(UIDefaultControls.ConvertToDefaultResources(resources));

            button.name = "ButtonEx";
            button.transform.Find("Text").GetComponent <Text>().text = "ButtonEx";
            button.AddComponent <DoubleClickable>();
            button.AddComponent <LongPressable>();
            return(button);
        }
Ejemplo n.º 3
0
        static GameObject CreateTextEx(UIResources resources)
        {
            GameObject text = DefaultControls.CreateText(UIDefaultControls.ConvertToDefaultResources(resources));

            text.name = "TextEx";
            text.AddComponent <VerticalText>().enabled  = false;
            text.AddComponent <ColorGradient>().enabled = false;
            text.AddComponent <Outline>().enabled       = false;
            text.AddComponent <Shadow>().enabled        = false;
            return(text);
        }
Ejemplo n.º 4
0
        static GameObject CreateRadarChart(UIResources resources)
        {
            GameObject radarPanel = DefaultControls.CreateImage(UIDefaultControls.ConvertToDefaultResources(resources));

            radarPanel.name = "RadarPanel";

            GameObject radarChart = new GameObject("RadarChart");
            RadarChart radar      = radarChart.AddComponent <RadarChart>();

            radar.color = Color.red;
            radarChart.transform.SetParent(radarPanel.transform);

            return(radarPanel);
        }
Ejemplo n.º 5
0
        static GameObject CreateGridView(UIResources resources)
        {
            GameObject gridViewObj = DefaultControls.CreateScrollView(UIDefaultControls.ConvertToDefaultResources(resources));

            gridViewObj.name = "GridView";
            GridView  gridView = gridViewObj.AddComponent <GridView>();
            Transform content  = gridView.transform.Find("Viewport").Find("Content");

            gridView.content = content as RectTransform;
            content.gameObject.AddComponent <GridLayoutGroup>();
            ScrollRect scrollRect = gridViewObj.GetComponentInChildren <ScrollRect>();

            scrollRect.movementType = ScrollRect.MovementType.Clamped;

            return(gridViewObj);
        }
Ejemplo n.º 6
0
        static GameObject CreateBubble(UIResources resources)
        {
            GameObject          chatBubble = new GameObject("Border", typeof(Image));
            VerticalLayoutGroup vlg        = chatBubble.AddComponent <VerticalLayoutGroup>();

            vlg.childControlWidth = vlg.childControlHeight = true;
            chatBubble.AddComponent <ContentSizeFitter>().verticalFit = ContentSizeFitter.FitMode.PreferredSize;

            GameObject spaceTop = new GameObject("SpaceTop");

            spaceTop.AddComponent <LayoutElement>().preferredHeight = 5;
            spaceTop.transform.SetParent(chatBubble.transform);

            GameObject            words = new GameObject("Words");
            HorizontalLayoutGroup hlg   = words.AddComponent <HorizontalLayoutGroup>();

            hlg.childControlWidth = hlg.childControlHeight = true;
            words.AddComponent <LayoutElement>();
            words.transform.SetParent(chatBubble.transform);

            GameObject spaceBottom = new GameObject("SpaceBottom");

            spaceBottom.AddComponent <LayoutElement>().preferredHeight = 5;
            spaceBottom.transform.SetParent(chatBubble.transform);



            GameObject spaceLeft = new GameObject("SpaceLeft");

            spaceLeft.AddComponent <LayoutElement>().preferredWidth = 10;
            spaceLeft.transform.SetParent(words.transform);

            GameObject text = DefaultControls.CreateText(UIDefaultControls.ConvertToDefaultResources(resources));

            text.AddComponent <LayoutElement>();
            text.transform.SetParent(words.transform);

            GameObject spaceRight = new GameObject("SpaceRight");

            spaceRight.AddComponent <LayoutElement>().preferredWidth = 10;
            spaceRight.transform.SetParent(words.transform);

            return(chatBubble);
        }
Ejemplo n.º 7
0
        static GameObject CreateJoyStick(UIResources resources)
        {
            GameObject stickPanel = DefaultControls.CreateImage(UIDefaultControls.ConvertToDefaultResources(resources));

            stickPanel.name = "StickPanel";

            GameObject stickSlider = CreateImageEx(UIMenuTools.GetStandardResources());

            stickSlider.name = "StickSlider";
            stickSlider.transform.localScale = new Vector3(0.6f, 0.6f, 1);

            JoyStick joyStick = stickSlider.AddComponent <JoyStick>();

            joyStick.dragable = stickSlider.GetComponent <UIDragable>();
            joyStick.panel    = stickPanel.transform as RectTransform;
            joyStick.slider   = stickSlider.transform as RectTransform;

            stickSlider.transform.SetParent(stickPanel.transform);

            return(stickPanel);
        }
Ejemplo n.º 8
0
        static GameObject CreateArcView(UIResources resources)
        {
            GameObject arc = DefaultControls.CreateImage(UIDefaultControls.ConvertToDefaultResources(resources));

            arc.name = "ArcView";
            Image background = arc.GetComponent <Image>();

            background.enabled       = false;
            background.raycastTarget = false;

            GameObject content = new GameObject("Content", typeof(RectTransform));

            content.transform.SetParent(arc.transform);

            GameObject btnSwitch = DefaultControls.CreateButton(UIDefaultControls.ConvertToDefaultResources(resources));

            btnSwitch.name = "BtnSwitch";
            btnSwitch.transform.SetParent(arc.transform);

            GameObject hotSpot = DefaultControls.CreateImage(UIDefaultControls.ConvertToDefaultResources(resources));

            hotSpot.name = "HotSpot";
            hotSpot.GetComponent <Image>().color = new Vector4(255, 255, 255, 0);
            UIDragable uiDragable = hotSpot.AddComponent <UIDragable>();

            uiDragable.rect = hotSpot.GetComponent <RectTransform>();
            hotSpot.transform.SetParent(arc.transform);
            PassPointerEvent passEvent = hotSpot.AddComponent <PassPointerEvent>();

            passEvent.passPointerClick = true;

            ArcView arcView = arc.AddComponent <ArcView>();

            arcView.panel     = arc.transform as RectTransform;
            arcView.content   = content.transform as RectTransform;
            arcView.hotSpot   = uiDragable;
            arcView.btnSwitch = btnSwitch.GetComponent <Button>();

            return(arc);
        }
Ejemplo n.º 9
0
        static GameObject CreateHeadHud(UIResources resources)
        {
            GameObject headHud = new GameObject("HeadHud");
            Canvas     canvas  = headHud.AddComponent <Canvas>();

            canvas.renderMode = RenderMode.WorldSpace;
            VerticalLayoutGroup layout = headHud.AddComponent <VerticalLayoutGroup>();

            layout.childAlignment         = TextAnchor.MiddleCenter;
            layout.childControlWidth      = true;
            layout.childControlHeight     = true;
            layout.childForceExpandWidth  = true;
            layout.childForceExpandHeight = true;
            Billboard billboard = headHud.AddComponent <Billboard>();

            billboard.trans = headHud.transform;

            GameObject hp = DefaultControls.CreateSlider(UIDefaultControls.ConvertToDefaultResources(resources));

            hp.name = "HP";
            GameObject.DestroyImmediate(hp.transform.Find("Handle Slide Area").gameObject);
            hp.transform.SetParent(headHud.transform);

            GameObject mp = DefaultControls.CreateSlider(UIDefaultControls.ConvertToDefaultResources(resources));

            mp.name = "MP";
            GameObject.DestroyImmediate(mp.transform.Find("Handle Slide Area").gameObject);
            mp.transform.SetParent(headHud.transform);

            GameObject name = DefaultControls.CreateText(UIDefaultControls.ConvertToDefaultResources(resources));

            name.name = "Name";
            name.transform.SetParent(headHud.transform);
            name.GetComponent <Text>().alignment = TextAnchor.MiddleCenter;

            return(headHud);
        }
Ejemplo n.º 10
0
        static GameObject CreateHorizontalScrollView(UIResources resources)
        {
            GameObject scroll = DefaultControls.CreateScrollView(UIDefaultControls.ConvertToDefaultResources(resources));

            scroll.name = "HScrollView";
            Transform toDel1 = scroll.transform.Find("Scrollbar Horizontal");
            Transform toDel2 = scroll.transform.Find("Scrollbar Vertical");

            GameObject.DestroyImmediate(toDel1.gameObject);
            GameObject.DestroyImmediate(toDel2.gameObject);

            RectTransform viewPort = scroll.transform.Find("Viewport") as RectTransform;

            ScrollRect scrollRect = scroll.GetComponent <ScrollRect>();

            scrollRect.vertical     = false;
            scrollRect.movementType = ScrollRect.MovementType.Clamped;

            RectTransform         content = viewPort.transform.Find("Content") as RectTransform;
            HorizontalLayoutGroup layout  = content.gameObject.AddComponent <HorizontalLayoutGroup>();

            layout.childAlignment         = TextAnchor.MiddleCenter;
            layout.childControlHeight     = layout.childControlWidth = false;
            layout.childForceExpandHeight = layout.childForceExpandWidth = true;
            content.sizeDelta             = Vector2.one * 100;
            content.anchorMin             = new Vector2(0, 0);
            content.anchorMax             = new Vector2(0, 1);

            SimpleScrollView ssv = scroll.AddComponent <SimpleScrollView>();

            ssv.scrollRect      = scrollRect;
            ssv.scrollDirection = SimpleScrollView.ScrollDirection.HORIZONTAL;
            ssv.content         = content;
            ssv.viewPort        = viewPort;

            return(scroll);
        }