Пример #1
0
        public void Awake()
        {
            rectTransform               = base.gameObject.AddComponent <RectTransform>();
            rectTransform.anchorMin     = Vector2.one / 2;
            rectTransform.anchorMax     = Vector2.one / 2;
            rectTransform.pivot         = Vector2.one / 2;
            rectTransform.localPosition = Vector3.zero;
            rectTransform.position      = Vector3.zero;
            rectTransform.sizeDelta     = new Vector2(300, 60);
            rectTransform.localScale    = Vector3.one;

            var color = new GameObject();

            color.transform.SetParent(transform);
            colorRectTransform = color.AddComponent <RectTransform>();
            var image = color.AddComponent <Image>();

            image.rectTransform.localPosition = Vector3.zero;
            image.rectTransform.anchorMin     = Vector2.zero;
            image.rectTransform.anchorMax     = Vector2.one;
            image.rectTransform.pivot         = Vector2.one / 2;
            image.color = new Color(0, 0, 0, 0.5f);

            var text1 = new GameObject();

            text1.transform.SetParent(transform);
            textContext1 = text1.AddComponent <RoR2.UI.HGTextMeshProUGUI>();
            textContext1.rectTransform.localPosition = Vector3.zero;
            textContext1.rectTransform.anchorMin     = Vector2.zero;
            textContext1.rectTransform.anchorMax     = Vector2.one;
            textContext1.rectTransform.pivot         = Vector2.one / 2;
            textContext1.enableAutoSizing            = false;
            textContext1.fontSizeMax = fontSize;
            textContext1.color       = Color.white;
            textContext1.alignment   = TMPro.TextAlignmentOptions.Top;
            textContext1.text        = "You will respawn";

            var text2 = new GameObject();

            text2.transform.SetParent(transform);
            textContext2 = text2.AddComponent <RoR2.UI.HGTextMeshProUGUI>();
            textContext2.rectTransform.localPosition = Vector3.zero;
            textContext2.rectTransform.anchorMin     = Vector2.zero;
            textContext2.rectTransform.anchorMax     = Vector2.one;
            textContext2.rectTransform.pivot         = Vector2.one / 2;
            textContext2.enableAutoSizing            = false;
            textContext2.fontSizeMax = fontSize;
            textContext2.color       = Color.white;
            textContext2.alignment   = TMPro.TextAlignmentOptions.Midline;
            textContext2.text        = "in x seconds";
        }
Пример #2
0
        internal void BuffIcon_Awake(On.RoR2.UI.BuffIcon.orig_Awake orig, RoR2.UI.BuffIcon self)
        {
            orig(self);
            if (self.transform.parent.name == "BuffDisplayRoot")
            {
                if (mod.config.BuffTooltips.Value)
                {
                    UnityEngine.UI.GraphicRaycaster raycaster = self.transform.parent.GetComponent <UnityEngine.UI.GraphicRaycaster>();
                    if (raycaster == null)
                    {
                        self.transform.parent.gameObject.AddComponent <UnityEngine.UI.GraphicRaycaster>();
                    }
                    self.gameObject.AddComponent <RoR2.UI.TooltipProvider>();
                }
                if (mod.config.BuffTimers.Value)
                {
                    GameObject                TimerText     = new GameObject("TimerText");
                    RectTransform             timerRect     = TimerText.AddComponent <RectTransform>();
                    RoR2.UI.HGTextMeshProUGUI timerTextMesh = TimerText.AddComponent <RoR2.UI.HGTextMeshProUGUI>();
                    TimerText.transform.SetParent(self.transform);

                    timerTextMesh.enableWordWrapping = false;
                    timerTextMesh.alignment          = mod.config.BuffTimersTextAlignmentOption;
                    timerTextMesh.fontSize           = mod.config.BuffTimersFontSize.Value;
                    timerTextMesh.faceColor          = Color.white;
                    timerTextMesh.text = "";

                    timerRect.localPosition    = Vector3.zero;
                    timerRect.anchorMin        = new Vector2(1, 0);
                    timerRect.anchorMax        = new Vector2(1, 0);
                    timerRect.localScale       = Vector3.one;
                    timerRect.sizeDelta        = new Vector2(48, 48);
                    timerRect.anchoredPosition = new Vector2(-24, 24);
                }
            }
        }
Пример #3
0
        internal override void HUD_Awake()
        {
            if (mod.config.StatsDisplayEnable.Value)
            {
                statsDisplayContainer = new GameObject("StatsDisplayContainer");
                RectTransform rectTransform = statsDisplayContainer.AddComponent <RectTransform>();

                if (mod.config.StatsDisplayAttachToObjectivePanel.Value)
                {
                    stupidBuffer = new GameObject("StupidBuffer");
                    RectTransform rectTransform3 = stupidBuffer.AddComponent <RectTransform>();
                    LayoutElement layoutElement2 = stupidBuffer.AddComponent <LayoutElement>();

                    layoutElement2.minWidth       = 0;
                    layoutElement2.minHeight      = 2;
                    layoutElement2.flexibleHeight = 1;
                    layoutElement2.flexibleWidth  = 1;

                    stupidBuffer.transform.SetParent(mod.HUD.objectivePanelController.objectiveTrackerContainer.parent.parent.transform);
                    statsDisplayContainer.transform.SetParent(mod.HUD.objectivePanelController.objectiveTrackerContainer.parent.parent.transform);

                    rectTransform.localPosition    = new Vector3(0, -10, 0);
                    rectTransform.anchorMin        = Vector2.zero;
                    rectTransform.anchorMax        = Vector2.one;
                    rectTransform.localScale       = new Vector3(1, -1, 1);
                    rectTransform.sizeDelta        = Vector2.zero;
                    rectTransform.anchoredPosition = new Vector2(0, 0);
                    rectTransform.eulerAngles      = new Vector3(0, 6, 0);
                }
                else
                {
                    statsDisplayContainer.transform.SetParent(mod.HUD.mainContainer.transform);

                    rectTransform.localPosition    = new Vector3(0, 0, 0);
                    rectTransform.anchorMin        = mod.config.StatsDisplayWindowAnchorMin.Value;
                    rectTransform.anchorMax        = mod.config.StatsDisplayWindowAnchorMax.Value;
                    rectTransform.localScale       = new Vector3(1, -1, 1);
                    rectTransform.sizeDelta        = mod.config.StatsDisplayWindowSize.Value;
                    rectTransform.anchoredPosition = mod.config.StatsDisplayWindowPosition.Value;
                    rectTransform.eulerAngles      = mod.config.StatsDisplayWindowAngle.Value;
                }


                VerticalLayoutGroup verticalLayoutGroup = statsDisplayContainer.AddComponent <UnityEngine.UI.VerticalLayoutGroup>();
                verticalLayoutGroup.padding = new RectOffset(5, 5, 10, 5);

                GameObject    statsDisplayText = new GameObject("StatsDisplayText");
                RectTransform rectTransform2   = statsDisplayText.AddComponent <RectTransform>();
                textMesh = statsDisplayText.AddComponent <RoR2.UI.HGTextMeshProUGUI>();
                LayoutElement layoutElement = statsDisplayText.AddComponent <LayoutElement>();

                statsDisplayText.transform.SetParent(statsDisplayContainer.transform);


                rectTransform2.localPosition    = Vector3.zero;
                rectTransform2.anchorMin        = Vector2.zero;
                rectTransform2.anchorMax        = Vector2.one;
                rectTransform2.localScale       = new Vector3(1, -1, 1);
                rectTransform2.sizeDelta        = Vector2.zero;
                rectTransform2.anchoredPosition = Vector2.zero;

                if (mod.config.StatsDisplayPanelBackground.Value)
                {
                    Image image     = statsDisplayContainer.AddComponent <UnityEngine.UI.Image>();
                    Image copyImage = mod.HUD.objectivePanelController.objectiveTrackerContainer.parent.GetComponent <Image>();
                    image.sprite = copyImage.sprite;
                    image.color  = copyImage.color;
                    image.type   = Image.Type.Sliced;
                }

                textMesh.fontSize     = 12;
                textMesh.fontSizeMin  = 6;
                textMesh.faceColor    = Color.white;;
                textMesh.outlineColor = Color.black;
                textMesh.fontMaterial.SetFloat(ShaderUtilities.ID_FaceDilate, 0.2f);
                textMesh.fontMaterial.SetFloat(ShaderUtilities.ID_OutlineWidth, 0.4f);

                layoutElement.minWidth       = 1;
                layoutElement.minHeight      = 1;
                layoutElement.flexibleHeight = 1;
                layoutElement.flexibleWidth  = 1;
            }
        }