Exemple #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);
        }
Exemple #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);
        }
Exemple #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);
        }
Exemple #4
0
        static GameObject CreateImageNumbers(UIResources resources)
        {
            GameObject go     = new GameObject("ImageNumbers");
            var        layout = go.AddComponent <HorizontalLayoutGroup>();

            layout.childControlWidth     = layout.childControlHeight = true;
            layout.childForceExpandWidth = layout.childForceExpandHeight = false;
            go.AddComponent <CanvasGroup>();
            go.AddComponent <NumFont>();

            return(go);
        }
Exemple #5
0
 public static DefaultControls.Resources ConvertToDefaultResources(UIResources resources)
 {
     DefaultControls.Resources res = new DefaultControls.Resources();
     res.background = resources.background;
     res.checkmark  = resources.checkmark;
     res.dropdown   = resources.dropdown;
     res.inputField = resources.inputField;
     res.knob       = resources.knob;
     res.mask       = resources.mask;
     res.standard   = resources.standard;
     return(res);
 }
Exemple #6
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);
        }
Exemple #7
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);
        }
Exemple #8
0
        static GameObject CreateCharacterPanel(UIResources resources)
        {
            GameObject characterPanel = new GameObject("CharacterPanel");

            characterPanel.AddComponent <Image>();
            characterPanel.AddComponent <Mask>();

            GameObject head = new GameObject("Head");

            head.AddComponent <Image>();

            GameObject hp = new GameObject("HP");

            hp.AddComponent <Image>();
            Slider hpSliderComp = hp.AddComponent <Slider>();

            GameObject hpSlider = new GameObject("HPSlider");

            hpSlider.AddComponent <Image>();
            hpSliderComp.fillRect  = hpSlider.transform as RectTransform;
            hpSliderComp.direction = Slider.Direction.LeftToRight;
            hpSliderComp.minValue  = 0;
            hpSliderComp.maxValue  = 1;
            hpSliderComp.value     = 1;
            hpSlider.transform.SetParent(hp.transform);

            GameObject mp = new GameObject("MP");

            mp.AddComponent <Image>();
            Slider mpSliderComp = mp.AddComponent <Slider>();

            GameObject mpSlider = new GameObject("MPSlider");

            mpSlider.AddComponent <Image>();
            mpSliderComp.fillRect  = mpSlider.transform as RectTransform;
            mpSliderComp.direction = Slider.Direction.LeftToRight;
            mpSliderComp.minValue  = 0;
            mpSliderComp.maxValue  = 1;
            mpSliderComp.value     = 1;
            mpSlider.transform.SetParent(mp.transform);

            head.transform.SetParent(characterPanel.transform);
            hp.transform.SetParent(characterPanel.transform);
            mp.transform.SetParent(characterPanel.transform);

            return(characterPanel);
        }
Exemple #9
0
        static GameObject CreateTVShow(UIResources resources)
        {
            GameObject tv       = new GameObject("TVShow");
            TVShow     tvShow   = tv.AddComponent <TVShow>();
            RawImage   tvScreen = tv.AddComponent <RawImage>();

            GameObject tvCamera = new GameObject("TVCamera", typeof(UnityEngine.Camera));

            tvCamera.transform.SetParent(tv.transform);
            UnityEngine.Camera cam = tvCamera.GetComponent <UnityEngine.Camera>();
            cam.clearFlags      = CameraClearFlags.SolidColor;
            cam.backgroundColor = new Color(0, 0, 0, 0);

            tvShow.tvCamera = cam;
            tvShow.tvScreen = tvScreen;

            return(tv);
        }
Exemple #10
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);
        }
Exemple #11
0
        static GameObject CreateVerticalTabView(UIResources resources)
        {
            GameObject tabViewObj = new GameObject("TabView", typeof(Image));
            TabView    tabView    = tabViewObj.AddComponent <TabView>();

            GameObject          contents = new GameObject("Contents");
            VerticalLayoutGroup layout   = contents.AddComponent <VerticalLayoutGroup>();

            layout.childAlignment         = TextAnchor.MiddleCenter;
            layout.childControlHeight     = layout.childControlWidth = false;
            layout.childForceExpandHeight = layout.childForceExpandWidth = false;
            ContentSizeFitter csf = contents.AddComponent <ContentSizeFitter>();

            csf.horizontalFit = ContentSizeFitter.FitMode.Unconstrained;
            csf.verticalFit   = ContentSizeFitter.FitMode.PreferredSize;

            tabView.contents = contents.transform as RectTransform;
            contents.transform.SetParent(tabViewObj.transform);

            return(tabViewObj);
        }
Exemple #12
0
        static GameObject CreateSwitch(UIResources resources)
        {
            GameObject switchOff     = new GameObject("Switch Off");
            Toggle     toggle        = switchOff.AddComponent <Toggle>();
            Image      targetGraphic = switchOff.AddComponent <Image>();
            GameObject switchOn      = new GameObject("Switch On");
            Image      graphic       = switchOn.AddComponent <Image>();

            switchOn.transform.SetParent(switchOff.transform);

            toggle.targetGraphic = targetGraphic;
            toggle.graphic       = graphic;

            (switchOn.transform as RectTransform).pivot     = new Vector2(0.5f, 0.5f);
            (switchOn.transform as RectTransform).anchorMin = Vector2.zero;
            (switchOn.transform as RectTransform).anchorMax = Vector2.one;
            (switchOn.transform as RectTransform).offsetMin = Vector2.zero;
            (switchOn.transform as RectTransform).offsetMax = Vector2.one;

            return(switchOff);
        }
Exemple #13
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);
        }
Exemple #14
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);
        }
Exemple #15
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);
        }
Exemple #16
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);
        }
Exemple #17
0
        static GameObject CreateFlipPage(UIResources resources)
        {
            GameObject book     = new GameObject("Book", typeof(RectTransform));
            FlipPage   flipPage = book.AddComponent <FlipPage>();

            /*GameObject border = new GameObject("Border", typeof(Image));
             * border.transform.parent = book.transform;
             * border.GetComponent<Image>().raycastTarget = false;*/

            GameObject left = new GameObject("Left", typeof(Image));

            (left.transform as RectTransform).pivot = Vector2.zero;
            left.transform.SetParent(book.transform);
            left.GetComponent <Image>().raycastTarget = false;
            left.GetComponent <Image>().enabled       = true;
            left.AddComponent <HorizontalLayoutGroup>().childAlignment = TextAnchor.MiddleCenter;

            GameObject right = new GameObject("Right", typeof(Image));

            (right.transform as RectTransform).pivot = Vector2.zero;
            right.transform.SetParent(book.transform);
            right.GetComponent <Image>().raycastTarget = false;
            right.GetComponent <Image>().enabled       = true;
            right.AddComponent <HorizontalLayoutGroup>().childAlignment = TextAnchor.MiddleCenter;

            GameObject leftOnFlip = new GameObject("LeftOnFlip", typeof(Image), typeof(Mask));

            (leftOnFlip.transform as RectTransform).pivot    = Vector2.zero;
            leftOnFlip.GetComponent <Mask>().showMaskGraphic = true;
            leftOnFlip.GetComponent <Image>().raycastTarget  = false;
            leftOnFlip.transform.SetParent(book.transform);
            leftOnFlip.SetActive(false);
            GameObject shadowLTR = new GameObject("ShadowLTR", typeof(Image));

            shadowLTR.transform.SetParent(leftOnFlip.transform);
            shadowLTR.GetComponent <Image>().raycastTarget = false;
            shadowLTR.SetActive(false);

            GameObject rightOnFlip = new GameObject("RightOnFlip", typeof(Image), typeof(Mask));

            (rightOnFlip.transform as RectTransform).pivot    = Vector2.zero;
            rightOnFlip.GetComponent <Mask>().showMaskGraphic = true;
            rightOnFlip.GetComponent <Image>().raycastTarget  = false;
            rightOnFlip.transform.SetParent(book.transform);
            rightOnFlip.SetActive(false);
            GameObject shadow = new GameObject("Shadow", typeof(Image));

            shadow.transform.SetParent(rightOnFlip.transform);
            shadow.GetComponent <Image>().raycastTarget = false;
            shadow.SetActive(false);

            GameObject turnPageFlip = new GameObject("TurnPageFlip", typeof(Image), typeof(Mask));

            turnPageFlip.GetComponent <Mask>().showMaskGraphic = false;
            turnPageFlip.GetComponent <Image>().raycastTarget  = false;
            turnPageFlip.transform.SetParent(book.transform);

            GameObject nextOnFlip = new GameObject("NextOnFlip", typeof(Image), typeof(Mask));

            nextOnFlip.GetComponent <Mask>().showMaskGraphic = false;
            nextOnFlip.GetComponent <Image>().raycastTarget  = false;
            nextOnFlip.transform.SetParent(book.transform);

            GameObject leftHotSpot = new GameObject("LeftHotSpot", typeof(Image), typeof(EventTrigger));

            leftHotSpot.GetComponent <Image>().color = new Vector4(1, 1, 1, 0);
            leftHotSpot.transform.SetParent(book.transform);

            GameObject rightHotSpot = new GameObject("RightHotSpot", typeof(Image), typeof(EventTrigger));

            rightHotSpot.GetComponent <Image>().color = new Vector4(1, 1, 1, 0);
            rightHotSpot.transform.SetParent(book.transform);

            flipPage.left          = left.GetComponent <Image>();
            flipPage.right         = right.GetComponent <Image>();
            flipPage.leftOnFlip    = leftOnFlip.GetComponent <Image>();
            flipPage.rightOnFlip   = rightOnFlip.GetComponent <Image>();
            flipPage.clippingPlane = turnPageFlip.GetComponent <Image>();
            flipPage.nextPageClip  = nextOnFlip.GetComponent <Image>();
            flipPage.shadow        = shadow.GetComponent <Image>();
            flipPage.shadowLTR     = shadowLTR.GetComponent <Image>();
            flipPage.leftHotSpot   = leftHotSpot.GetComponent <Image>();
            flipPage.rightHotSpot  = rightHotSpot.GetComponent <Image>();

            return(book);
        }