public void Apply(UIText target)
 {
     target.font = _fonts[fontIndex].font;
     target.fontSize = (int)fontSize;
     target.fontStyle = (FontStyle)(fontStyle & 0b_11);
     target.lineSpacing = lineSpacing + 1;
 }
Beispiel #2
0
 public Text(TMPro.TMP_Text text = null)
 {
     this.text = text; if (text)
     {
         root = text.transform.root;
     }
 }
Beispiel #3
0
        public void Init()
        {
            TMPro.TMP_InputField tif = GetComponentInChildren <TMPro.TMP_InputField>();
            if (tif != null)
            {
                EventBind.IfNotAlready(setText, tif, "set_text"); getText = () => tif.text;
            }
            TMPro.TMP_Text tmp = GetComponentInChildren <TMPro.TMP_Text>();
            if (tmp != null)
            {
                EventBind.IfNotAlready(setText, tmp, "set_text"); getText = () => tmp.text;
            }
            InputField inf = GetComponentInChildren <InputField>();

            if (inf != null)
            {
                EventBind.IfNotAlready(setText, inf, "set_text"); getText = () => inf.text;
            }
            Text txt = GetComponentInChildren <Text>();

            if (txt != null)
            {
                EventBind.IfNotAlready(setText, txt, "set_text"); getText = () => txt.text;
            }
            if (UiImage.HasImageHolder(gameObject))
            {
                EventBind.IfNotAlready(setText, this, SetImageByName); getText = GetImageName;
            }
        }
Beispiel #4
0
        public static Component GetTextComponent(GameObject go)
        {
            UiText uit = go.GetComponentInChildren <UiText>();

            if (uit != null)
            {
                return(uit);
            }
            TMPro.TMP_InputField tif = go.GetComponentInChildren <TMPro.TMP_InputField>();
            if (tif != null)
            {
                return(tif);
            }
            TMPro.TMP_Text tmp = go.GetComponentInChildren <TMPro.TMP_Text>();
            if (tmp != null)
            {
                return(tmp);
            }
            InputField inf = go.GetComponentInChildren <InputField>();

            if (inf != null)
            {
                return(inf);
            }
            Text txt = go.GetComponentInChildren <Text>();

            if (txt != null)
            {
                return(txt);
            }
            return(null);
        }
Beispiel #5
0
        public static string GetText(GameObject go)
        {
            UiText uit = go.GetComponentInChildren <UiText>();

            if (uit != null && uit.getText != null)
            {
                return(uit.getText.Invoke());
            }
            TMPro.TMP_InputField tif = go.GetComponentInChildren <TMPro.TMP_InputField>();
            if (tif != null)
            {
                return(tif.text);
            }
            TMPro.TMP_Text tmp = go.GetComponentInChildren <TMPro.TMP_Text>();
            if (tmp != null)
            {
                return(tmp.text);
            }
            InputField inf = go.GetComponentInChildren <InputField>();

            if (inf != null)
            {
                return(inf.text);
            }
            Text txt = go.GetComponentInChildren <Text>();

            if (txt != null)
            {
                return(txt.text);
            }
            return(null);
        }
Beispiel #6
0
            private void Awake()
            {
                ludumDareButton = GameObject.Find("LudumDareButton").GetComponent <Button>();
                ludumDareButton.onClick.AddListener(() => { Application.OpenURL("https://ldjam.com/"); /* little easter egg :) */ });

                timeText = GameObject.Find("OSTimeText").GetComponent <TMPro.TMP_Text>();
            }
Beispiel #7
0
        private void UpdateInfo()
        {
            if (this.game != null && this.game.world != null)
            {
                var world               = (ME.ECS.IWorld <State>) this.game.world;
                var tick                = world.GetStateTick();
                var time                = world.GetTimeSinceStart();
                var historyModule       = world.GetModule <ME.ECS.StatesHistory.IStatesHistoryModule <State> >();
                var eventsAddedCount    = historyModule.GetEventsAddedCount();
                var networkModule       = world.GetModule <ME.ECS.Network.NetworkModule <State> >();
                var eventsSentCount     = networkModule.GetEventsSentCount();
                var eventsReceivedCount = networkModule.GetEventsReceivedCount();

                this.text.text = "World Id: " + world.id.ToString() +
                                 "\nDT Multiplier: " + this.game.deltaTimeMultiplier.ToString() +
                                 "\nConnected World: " + this.game.worldConnectionId.ToString() +
                                 "\nTick: " + tick.ToString() +
                                 "\nTime: " + time.ToString() +
                                 "\nEvents Added: " + eventsAddedCount.ToString() +
                                 "\nSent: " + eventsSentCount.ToString() +
                                 "\nReceived: " + eventsReceivedCount.ToString() +
                                 "\nSyncTick: " + networkModule.GetSyncTick().ToString() +
                                 "\nSyncTickSent: " + networkModule.GetSyncSentTick().ToString();
            }
        }
Beispiel #8
0
        public static Component SetText(GameObject go, string value)
        {
            //Show.Log("setting "+go.name+" to \""+value+"\"");
            UiText uit = go.GetComponentInChildren <UiText>();

            if (uit != null)
            {
                uit.setText.Invoke(value); return(uit);
            }
            TMPro.TMP_InputField tif = go.GetComponentInChildren <TMPro.TMP_InputField>();
            if (tif != null)
            {
                tif.text = value; return(tif);
            }
            TMPro.TMP_Text tmp = go.GetComponentInChildren <TMPro.TMP_Text>();
            if (tmp != null)
            {
                tmp.text = value; return(tmp);
            }
            InputField inf = go.GetComponentInChildren <InputField>();

            if (inf != null)
            {
                inf.text = value; return(inf);
            }
            Text txt = go.GetComponentInChildren <Text>();

            if (txt != null)
            {
                txt.text = value; return(txt);
            }
            return(null);
        }
Beispiel #9
0
        // NOTE [bgish]: has zero references bcause AnimateToGoal refers to this function by string name
        private IEnumerator AnimateToGoalCoroutine()
        {
            if (this.HasValueBeenSet == false)
            {
                this.intValue  = 0;
                this.text.text = "0";
            }

            this.onStartAnimation.InvokeIfNotNull();

            float startValue    = this.intValue;
            float endValue      = this.goalValue;
            float difference    = endValue - startValue;
            float animationTime = this.animationCurve.keys.Last().time;
            float currentTime   = 0;

            while (currentTime < animationTime)
            {
                float newValue = startValue + (difference * this.animationCurve.Evaluate(currentTime));

                this.intValue = (int)newValue;
                this.UpdateText();

                yield return(null);

                currentTime += Time.deltaTime;
            }

            this.intValue = this.goalValue;
            this.UpdateText();

            this.onEndAnimation.InvokeIfNotNull();
        }
Beispiel #10
0
        public void switchToInspectPage()
        {
            PdaPage inspectPage = pages.Find(x => x.pageType == PdaPageType.Inspect);

            if (currentPage == null)
            {
                currentPage = GameObject.Instantiate(inspectPage.gameObject, transform).GetComponent <PdaPage>();
            }
            else if (currentPage.pageType != PdaPageType.Inspect)
            {
                GameObject.Destroy(currentPage.gameObject);
                currentPage = GameObject.Instantiate(inspectPage.gameObject, transform).GetComponent <PdaPage>();
            }

            TMPro.TMP_Text[] textComponents = currentPage.gameObject.GetComponentsInChildren <TMPro.TMP_Text>();
            TMPro.TMP_Text   textField      = null;
            foreach (TMPro.TMP_Text textComp in textComponents)
            {
                if (textComp.gameObject.name == "Content")
                {
                    textField = textComp;
                }
            }
            if (textField != null)
            {
                textField.SetText(currentInspectContent);
            }
        }
Beispiel #11
0
        public CustomMessage(string message, float duration)
        {
            RoomTracker roomTracker = HudManager.Instance?.roomTracker;

            if (roomTracker != null)
            {
                GameObject gameObject = UnityEngine.Object.Instantiate(roomTracker.gameObject);

                gameObject.transform.SetParent(HudManager.Instance.transform);
                UnityEngine.Object.DestroyImmediate(gameObject.GetComponent <RoomTracker>());
                text      = gameObject.GetComponent <TMPro.TMP_Text>();
                text.text = message;

                // Use local position to place it in the player's view instead of the world location
                gameObject.transform.localPosition = new Vector3(0, -1.8f, gameObject.transform.localPosition.z);
                customMessages.Add(this);

                HudManager.Instance.StartCoroutine(Effects.Lerp(duration, new Action <float>((p) => {
                    bool even     = ((int)(p * duration / 0.25f)) % 2 == 0; // Bool flips every 0.25 seconds
                    string prefix = (even ? "<color=#FCBA03FF>" : "<color=#FF0000FF>");
                    text.text     = prefix + message + "</color>";
                    if (text != null)
                    {
                        text.color = even ? Color.yellow : Color.red;
                    }
                    if (p == 1f && text != null && text.gameObject != null)
                    {
                        UnityEngine.Object.Destroy(text.gameObject);
                        customMessages.Remove(this);
                    }
                })));
            }
        }
Beispiel #12
0
        public static void fortuneTellerMessage(string message, float duration, Color color)
        {
            RoomTracker roomTracker = HudManager.Instance?.roomTracker;

            if (roomTracker != null)
            {
                GameObject gameObject = UnityEngine.Object.Instantiate(roomTracker.gameObject);

                gameObject.transform.SetParent(HudManager.Instance.transform);
                UnityEngine.Object.DestroyImmediate(gameObject.GetComponent <RoomTracker>());

                // Use local position to place it in the player's view instead of the world location
                gameObject.transform.localPosition = new Vector3(0, -1.8f, gameObject.transform.localPosition.z);
                gameObject.transform.localScale   *= 1.5f;

                text       = gameObject.GetComponent <TMPro.TMP_Text>();
                text.text  = message;
                text.color = color;

                HudManager.Instance.StartCoroutine(Effects.Lerp(duration, new Action <float>((p) =>
                {
                    if (p == 1f && text != null && text.gameObject != null)
                    {
                        UnityEngine.Object.Destroy(text.gameObject);
                    }
                })));
            }
        }
Beispiel #13
0
        void Start()
        {
            Text = name;
            transform.rotation = cam.transform.rotation;
            Rigidbody rb = GetComponent <Rigidbody>();

            rb.velocity = Vector3.up * speed;
            long timing = (long)(duration * 1000);

            GameClock.Delay(timing, () => Destroy(gameObject));
            if (fade)
            {
                TMPro.TMP_Text tt = TmpText;
                Color          originalFace = tt.faceColor, originalOutline = tt.outlineColor;
                Proc.SystemClock.Lerp(p => {
                    if (tt != null)
                    {
                        tt.faceColor       = Color.Lerp(originalFace, Color.clear, p);
                        tt.outlineColor    = Color.Lerp(originalOutline, Color.clear, p);
                        transform.rotation = cam.transform.rotation;
                    }
                    //Show.Log(p);
                }, timing, 10);
            }
        }
        public void GiveInventoryTo(TMPro.TMP_Text textElement)
        {
            string outText = dict.Stringify(true);

            Debug.Log(outText);
            textElement.text = outText;
        }
Beispiel #15
0
        /// <summary>Alternative inspector control (eg: EditorGUILayout.SpriteField) for Image.sprite/VectorImage.vectorImageData/Text.text. Supports undo/redo.</summary>
        /// <param name="label">The label to appear in the inspector control.</param>
        /// <param name="graphic">The Graphic to modify.</param>
        /// <param name="disableIfMultipleObjectsSelected">Is this field drawn disabled if multiple GameObjects are selected?</param>
        /// <returns>Whether the control was successfully able to be drawn.</returns>
        public static bool GraphicField(string label, Graphic graphic, bool disableIfMultipleObjectsSelected = true)
        {
            using (new DisabledScope(TooManySelected(!disableIfMultipleObjectsSelected)))
            {
                Image image = graphic as Image;
                if (image != null)
                {
                    ImageField(label, image, disableIfMultipleObjectsSelected);
                    return(true);
                }

                IVectorImage vectorImage = graphic as IVectorImage;
                if (graphic != null && vectorImage != null)
                {
                    VectorImageField(label, vectorImage, disableIfMultipleObjectsSelected);
                    return(true);
                }

                Text text = graphic as Text;
                if (text != null)
                {
                    TextField(label, text);
                    return(true);
                }

                TMPro.TMP_Text textTmp = graphic as TMPro.TMP_Text;
                if (textTmp != null)
                {
                    TMPTextField(label, textTmp);
                    return(true);
                }
            }

            return(false);
        }
 private void OnValidate()
 {
     if (!text)
     {
         text = GetComponent <TMPro.TMP_Text>();
     }
 }
Beispiel #17
0
 void Start()
 {
     slider       = GetComponent <Slider>();
     text         = _難易度.GetComponent <TMPro.TMP_Text>();
     text.text    = titleSettings.LeaderCount.ToString();
     slider.value = titleSettings.LeaderCount;
 }
Beispiel #18
0
        // Private Methods

        private void CreateText(GameObject prefab, ref Text textComponent, string name, UIPivot pivot, UIAnchor anchor, Vector2 offset)
        {
            if (prefab == null || content == null)
            {
                return;
            }
            if (textComponent != null)
            {
                Debug.LogError("Window already has " + name + "!");
                return;
            }

            GameObject instance = UITools.InstantiateGUIObject <Text>(
                prefab,
                content.transform,
                name,
                pivot,
                anchor.min,
                anchor.max,
                offset
                );

            if (instance == null)
            {
                return;
            }
            textComponent = instance.GetComponent <Text>();
        }
Beispiel #19
0
        public void AddContentText(GameObject prefab, UIPivot pivot, UIAnchor anchor, Vector2 offset)
        {
            Text text = null;

            CreateText(prefab, ref text, "Content Text", pivot, anchor, offset);
            _contentText.Add(text);
        }
 public GUIToggle(Toggle toggle, Text label)
     : base(toggle, label)
 {
     if (!Init())
     {
         return;
     }
 }
 public GUIInputField(Button button, Text label)
     : base(button, label)
 {
     if (!Init())
     {
         return;
     }
 }
 public GUIButton(Button button, Text label)
     : base(button, label)
 {
     if (!Init())
     {
         return;
     }
 }
 public GUILabel(Text label)
 {
     this.text = label;
     if (!Check())
     {
         return;
     }
 }
Beispiel #24
0
 private void select()
 {
     if (targetText == null)
     {
         targetText = GetComponent <TMPro.TMP_Text>();
     }
     targetText.text = Language.GetString(TextIndex);
 }
Beispiel #25
0
 private void UpdateTextButton()
 {
     if (text == null)
     {
         text = GetComponent <TMPro.TMP_Text>();
     }
     UpdateText();
 }
Beispiel #26
0
    public void ReplaceTextMeshProText(TMPro.TMP_Text newValue)
    {
        var index     = GameComponentsLookup.TextMeshProText;
        var component = (TextMeshProText)CreateComponent(index, typeof(TextMeshProText));

        component.value = newValue;
        ReplaceComponent(index, component);
    }
Beispiel #27
0
        private void adjustTextLabelSize(Transform label, TMPro.TMP_Text txtObj, float width, float height, float depth)
        {
            label.localScale = new Vector3(width, height, depth);
            txtObj.rectTransform.sizeDelta          = new Vector2(width, height);
            txtObj.rectTransform.anchoredPosition3D = new Vector3(width * 0.5f, height * -0.5f, depth * 0.501f);

            txtObj.ForceMeshUpdate();
        }
Beispiel #28
0
            public static void Postfix(CreateOptionsPicker __instance)
            {
                List <SpriteRenderer> maxPlayerButtons = __instance.MaxPlayerButtons.ToList();

                if (maxPlayerButtons == null || maxPlayerButtons.Count <= 2)
                {
                    return;
                }
                additionalButtons = new List <SpriteRenderer>();

                for (int i = 1; i < 6; i++)
                {
                    SpriteRenderer nextButton = Object.Instantiate(maxPlayerButtons.Last(), maxPlayerButtons.Last().transform.parent);
                    additionalButtons.Add(nextButton);
                    nextButton.enabled         = false;
                    nextButton.gameObject.name = "1" + i;
                    TMPro.TMP_Text text = nextButton.gameObject.GetComponentInChildren <TMPro.TMP_Text>();
                    text.text  = "1" + i;
                    text.color = Helpers.isCustomServer() ? Color.white : Palette.EGHCBLDNCGP;

                    nextButton.transform.position = nextButton.transform.position + new Vector3(i * (maxPlayerButtons[1].transform.position.x - maxPlayerButtons[0].transform.position.x), 0, 0);
                    var passiveButton = nextButton.GetComponent <PassiveButton>();
                    passiveButton.OnClick.RemoveAllListeners();

                    void onClick()
                    {
                        bool isCustom = Helpers.isCustomServer();

                        foreach (SpriteRenderer renderer in additionalButtons)
                        {
                            if (renderer != null && renderer.gameObject != null)
                            {
                                renderer.enabled = false;
                                renderer.gameObject.GetComponentInChildren <TMPro.TMP_Text>().color = isCustom ? Color.white : Palette.EGHCBLDNCGP;
                            }
                        }

                        if (!isCustom)
                        {
                            return;
                        }

                        nextButton.enabled = true;

                        byte value         = byte.Parse(nextButton.name);
                        var  targetOptions = __instance.GetTargetOptions();

                        if (value <= targetOptions.DIGMGCJMGDB)
                        {
                            targetOptions.DIGMGCJMGDB = value - 1;
                            __instance.SetImpostorButtons(targetOptions.DIGMGCJMGDB);
                        }
                        __instance.SetMaxPlayersButtons(value);
                    }

                    passiveButton.OnClick.AddListener((UnityEngine.Events.UnityAction)onClick);
                }
            }
Beispiel #29
0
        public static void SetMultilanguageText(this TMPro.TMP_Text text, string key)
        {
            string value = GetValue(text, key);

            if (value != null)
            {
                text.text = value;
            }
        }
Beispiel #30
0
        public static void SetMultilanguageText(this TMPro.TMP_Text text, string key, params object[] args)
        {
            string value = GetValue(text, key);

            if (value != null)
            {
                text.text = string.Format(value, args);
            }
        }