Example #1
0
 // Start is called before the first frame update
 void Start()
 {
     message[1]    += System.DateTime.Now.ToString("yyyy-MM-dd");
     player         = GameObject.FindGameObjectWithTag("Player");
     control        = player.GetComponent <PlayerControl>();
     playerRenderer = player.GetComponent <SpriteRenderer>();
     image          = this.GetComponentInChildren <Image>();
     startScreen    = this.transform.Find("StartScreen").gameObject;
     cutScene       = this.transform.Find("CutScene").gameObject;
     if (startScreen != null)
     {
         title      = startScreen.transform.Find("Title").GetComponent <TMPro.TextMeshProUGUI>();
         subTitle   = startScreen.transform.Find("SubTitle").GetComponent <TMPro.TextMeshProUGUI>();
         indication = startScreen.transform.Find("Indication").GetComponent <TMPro.TextMeshProUGUI>();
         underLine  = startScreen.transform.Find("UnderLine").GetComponent <TMPro.TextMeshProUGUI>();
     }
     if (cutScene != null)
     {
         runMessage = cutScene.transform.Find("RunMessage").GetComponent <TMPro.TextMeshProUGUI>();
         error      = cutScene.transform.Find("Error").GetComponent <TMPro.TextMeshProUGUI>();
         suggestion = cutScene.transform.Find("Suggestion").GetComponent <TMPro.TextMeshProUGUI>();
     }
     if (level != null)
     {
         levelSprites = level.GetComponentsInChildren <SpriteRenderer>();
     }
     control.isCutScene = true;
     audioManager       = GameObject.Find("SceneAudioManager").GetComponent <SceneAudioManager>();
     StartCoroutine(PlayCutScene());
 }
Example #2
0
 /// <summary>
 /// Start is called on the frame when a script is enabled just before
 /// any of the Update methods is called the first time.
 /// </summary>
 void Start()
 {
     if (!waveText)
     {
         waveText = GetComponent <TMPro.TextMeshProUGUI>();
     }
 }
Example #3
0
 private void CreateText()
 {
     hudText             = BeatSaberUI.CreateText(_mainMenuRectTransform, "Matchmaking...", new Vector2(55.5f, 33f));
     hudText.fontSize    = 5f;
     hudText.lineSpacing = -52;
     hudText.gameObject.SetActive(false);
 }
Example #4
0
    //Slowly draws text on a screen. Skippable.
    IEnumerator DrawText(string text, string speakerName)
    {
        TMPro.TextMeshProUGUI storyText = Instantiate(textPrefab) as TMPro.TextMeshProUGUI;
        storyText.transform.SetParent(textArea.transform, false);
        storyText.maxVisibleCharacters = 0;

        Assert.IsTrue(speakersDic.ContainsKey(speakerName));
        DialogueConfig speaker  = speakersDic[speakerName];
        string         addColor = TagsUtility.AddColorTag(text, speaker.speaker_color);

        storyText.text    += addColor;
        storyText.font     = speaker.font;
        storyText.fontSize = textSize;

        for (int i = 0; i < text.Length; i++)
        {
            if (mouseKeyPressed)
            {
                mouseKeyPressed = false;
                storyText.maxVisibleCharacters += (text.Length - i);
                break;
            }
            storyText.maxVisibleCharacters++;
            yield return(new WaitForSeconds(speaker.time_between_characters));
        }

        yield return(new WaitForSeconds(speaker.time_between_sentences));

        RefreshView();
    }
    void SetGUI()
    {
        //Find each text component in the current scene
        textHealth  = GameObject.Find("Health").GetComponent <TMPro.TextMeshProUGUI>();
        textStamina = GameObject.Find("Stamina").GetComponent <TMPro.TextMeshProUGUI>();
        textMana    = GameObject.Find("Mana").GetComponent <TMPro.TextMeshProUGUI>();
        lvlComplete = GameObject.Find("LevelCompleted");

        //Set values of each text component
        textHealth.text  = health.ToString();
        textStamina.text = stamina.ToString();
        textMana.text    = mana.ToString();
        lvlComplete.SetActive(false);

        //Find each image component in the current scene
        imgDamage = GameObject.Find("SwordImg").GetComponent <Image>();
        imgArmour = GameObject.Find("ArmourImg").GetComponent <Image>();
        imgBoots  = GameObject.Find("BootsImg").GetComponent <Image>();

        //Set values of each image component
        imgDamage.enabled = false;
        imgBoots.enabled  = false;
        imgArmour.enabled = false;

        respawnButton = GameObject.Find("Respawn");
        respawnButton.SetActive(false);
    }
 private void Start()
 {
     textDialogue = PanelDialogue.GetComponentInChildren <TextMeshProUGUI>();
     ClosePanels();
     PanelDialogue.SetActive(false);
     keycodeCooldown = true;
 }
 // Use this for initialization
 void Start()
 {
     buttonText      = gameObject.GetComponent <TMPro.TextMeshProUGUI>();
     categories      = gameObject.GetComponentInParent <Categories>().display_categories;
     value           = categories[this.id];
     buttonText.text = Reverse(value);
 }
    // Start is called before the first frame update
    void Start()
    {
        string[] vecText = new string[] { "RESUME GAME", "BACK MENU INITIAL", "QUIT GAME", "CONTINUAR JUEGO",
                                          "REGRESAR AL MENU", "QUITAR JUEGO" };

        int veracidad = PlayerPrefs.GetInt("Option", 0);

        this.txtTextMeshPro = GetComponent <TMPro.TextMeshProUGUI>();

        int valueLanguage = PlayerPrefs.GetInt("Language", 0);

        if (valueLanguage == 0)
        {
            switch (value)
            {
            case (0): this.AgregarTextoTextMeshPro(vecText, 0); break;

            case (1): this.AgregarTextoTextMeshPro(vecText, 1); break;

            case (2): this.AgregarTextoTextMeshPro(vecText, 2); break;
            }
        }
        else
        {
            switch (value)
            {
            case (0): this.AgregarTextoTextMeshPro(vecText, 3); break;

            case (1): this.AgregarTextoTextMeshPro(vecText, 4); break;

            case (2): this.AgregarTextoTextMeshPro(vecText, 5); break;
            }
        }
    }
Example #9
0
    private void AddText(string text, int indent)
    {
        if (ContentRect != null)
        {
            float panelWidth = ContentRect.rect.width;

            if (text != null)
            {
                TMPro.TextMeshProUGUI obj = Instantiate(LogTextPrefab);
                var margin = obj.margin;
                margin.x   = indent * 10;
                obj.margin = margin;
                obj.SetText(text);
                obj.transform.SetParent(Content.transform);
                float preferredHeight = obj.GetPreferredValues(panelWidth - margin.x, 0f).y;
                obj.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, preferredHeight);
                this.contentHeight += preferredHeight;
                ContentRect.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, this.contentHeight);
                obj.rectTransform.localScale    = Vector3.one;
                obj.rectTransform.localRotation = Quaternion.identity;
                var pos = obj.rectTransform.localPosition;
                pos.z = 0f;
                obj.rectTransform.localPosition = pos;
                Items.Add(obj);
                //Dirty = true;
                Invoke("ScrollToBottom", 0.1f);
            }
        }
    }
Example #10
0
    public void Initialize(OpCode op)
    {
        this.command = op;

        this.revealed = false;
        this.obfuscator.SetActive(true);

        transform.SetAsLastSibling();

        instructionHeader      = transform.Find("Header").GetComponentInChildren <TMPro.TextMeshProUGUI>();
        instructionHeader.text = command.ToString();
        instructionDescription = transform.Find("Description").GetComponentInChildren <TMPro.TextMeshProUGUI>();

        GameObject instructionObj = PuzzleGenerator.GetComponent <InstructionFactory>().SpawnInstruction(this.command, instructionHeader.transform);

        instructionDescription.text = instructionObj.GetComponent <Command>().Description;

        // Get rid of unnecessary components
        Destroy(instructionObj.GetComponent <UIControl>());
        Destroy(instructionObj.GetComponent <DragNDrop>());
        Destroy(instructionObj.GetComponent <GraphicRaycaster>());
        Destroy(instructionObj.GetComponent <Canvas>());

        instructionObj.GetComponent <RectTransform>().anchorMin        = Vector2.zero;
        instructionObj.GetComponent <RectTransform>().anchorMax        = Vector2.one;
        instructionObj.GetComponent <RectTransform>().sizeDelta        = Vector2.zero;
        instructionObj.GetComponent <RectTransform>().anchoredPosition = instructionHeader.GetComponent <RectTransform>().anchoredPosition;
        instructionObj.GetComponent <RectTransform>().localScale       = new Vector3(1.75f, 1.75f, 1.75f);
    }
Example #11
0
 // Start is called before the first frame update
 void Start()
 {
     levelset1 = 1;
     levelset2 = 0;
     if (PlayerPrefs.GetInt("Audio", 1) == 1)
     {
         bgsound.volume = 0;
         bgsound.Play();
         StartCoroutine(SlowStartBgSound());
         stompfx.SetActive(true);
         swooshfx.SetActive(true);
         bgsoundsource.SetActive(true);
     }
     else
     {
         stompfx.SetActive(false);
         swooshfx.SetActive(false);
         bgsoundsource.SetActive(false);
     }
     started = false;
     playerscript.reading = false;
     panel.SetActive(false);
     level          = 1; //change initial level for testing
     levelbartext   = levelbar.GetComponent <TextMeshProUGUI>();
     playerscript   = GameObject.Find("Player").GetComponent <Player>();
     Time.timeScale = 0f;
     Startbtn.SetActive(true);
     instruct1.SetActive(true);
     instruct2.SetActive(true);
     instruct3.SetActive(true);
     instruct4.SetActive(true);
     resumebtn.SetActive(false);
     paused = false;
 }
Example #12
0
        // CHARACTER HANDLING

        /// <summary>
        /// Function returning the index of the character at the given position (if any).
        /// </summary>
        /// <param name="text">A reference to the TextMeshPro UGUI component.</param>
        /// <param name="position">Position to check for intersection.</param>
        /// <param name="camera"></param>
        /// <param name="visibleOnly">Only check for visible characters.</param>
        /// <returns></returns>
        public static int FindIntersectingCharacter(TextMeshProUGUI text, Vector3 position, Camera camera, bool visibleOnly)
        {
            RectTransform rectTransform = text.rectTransform;

            // Convert position into Worldspace coordinates
            ScreenPointToWorldPointInRectangle(rectTransform, position, camera, out position);

            for (int i = 0; i < text.textInfo.characterCount; i++)
            {
                // Get current character info.
                TMP_CharacterInfo cInfo = text.textInfo.characterInfo[i];
                if (visibleOnly && !cInfo.isVisible)
                    continue;

                // Get Bottom Left and Top Right position of the current character
                Vector3 bl = rectTransform.TransformPoint(cInfo.bottomLeft);
                Vector3 tl = rectTransform.TransformPoint(new Vector3(cInfo.bottomLeft.x, cInfo.topRight.y, 0));
                Vector3 tr = rectTransform.TransformPoint(cInfo.topRight);
                Vector3 br = rectTransform.TransformPoint(new Vector3(cInfo.topRight.x, cInfo.bottomLeft.y, 0));

                if (PointIntersectRectangle(position, bl, tl, tr, br))
                    return i;

            }
            return -1;
        }
 // Start is called before the first frame update
 void Start()
 {
     scoreText = GameObject
                 .FindGameObjectWithTag("ScoreText")
                 .GetComponent <TMPro.TextMeshProUGUI>();
     scoreText.text = currentScore.ToString();
 }
Example #14
0
        protected override IEnumerator AfterStart()
        {
            this.RegisterSelf(this);

            _multTextMeshProText = _multTextMeshProText.GetComponentFromDescendants(this, nameof(_multTextMeshProText));
            _multSkillButton     = _multSkillButton.GetComponentFromDescendants(this, nameof(_multSkillButton));
            _plusTextMeshProText = _plusTextMeshProText.GetComponentFromDescendants(this, nameof(_plusTextMeshProText));
            _plusSkillButton     = _plusSkillButton.GetComponentFromDescendants(this, nameof(_plusSkillButton));
            yield return(BrickMgrM.WaitModule <IPropertyTag>());

            yield return(null);

            //按下按键尝试释放
            _multSkillButton.OnClickAsObservable().Subscribe(__ =>
            {
                MessageBroker.Default.Publish(new SkillTag_TryModifySkill());
                MessageBroker.Default.Publish(new PropTag_ModifyMultiplyCount {
                    value = -1
                });
            }).AddTo(this);
            _plusSkillButton.OnClickAsObservable().Subscribe(__ =>
            {
                MessageBroker.Default.Publish(new SkillTag_TryPlusSkill());
                MessageBroker.Default.Publish(new PropTag_ModifyPlusCount {
                    value = -1
                });
            }).AddTo(this);
            // ----------------------
            //更新plus
            BrickMgrM.PropertyModule.plusCount.current.SubscribeWithState(_plusTextMeshProText, (x, t) => t.text = x.ToString()).AddTo(this);
            //更新mult
            BrickMgrM.PropertyModule.multiplyCount.current.SubscribeWithState(_multTextMeshProText, (x, t) => t.text = x.ToString()).AddTo(this);
        }
Example #15
0
    public override void gaxb_complete()
    {
        base.gaxb_complete ();

        m_TextComponent = gameObject.GetComponent<TextMeshProUGUI>();

        TMPro_EventManager.TEXT_CHANGED_EVENT.Add (UpdateTextToFitCurve);
    }
 public Timer(int startTime, int duration, TMPro.TextMeshProUGUI text, Interaction interaction)
 {
     StartTime   = startTime;
     Duration    = duration;
     Text        = text;
     Interaction = interaction;
     Finished    = false;
 }
Example #17
0
        internal void init()
        {
            currentEnergyText = transform.FindChild("CurrentEnergyText").GetComponent<TextMeshProUGUI>();
            maxEnergyText = transform.FindChild("MaxEnergyText").GetComponent<TextMeshProUGUI>();

            var energyBar = GameObject.Find("EnergyContainer").gameObject;
            fillRenderer = energyBar.transform.FindChild("EnergyBarFill").GetComponent<MeshRenderer>();
        }
Example #18
0
 internal void init(PlayerResourcesModel playerResources, PieceModel piece)
 {
     abilityButton.onClick.AddListener(() => onClick());
     abilityButton.interactable = false;
     buttonText = abilityButton.GetComponentInChildren<TextMeshProUGUI>();
     this.playerResources = playerResources;
     this.piece = piece;
 }
Example #19
0
 protected override void Awake()
 {
     rectTransform = GetComponent<RectTransform>();
     displayWrapper = transform.Find("DisplayWrapper").gameObject;
     text = displayWrapper.GetComponentInChildren<TextMeshProUGUI>();
     DeckGO = GameObject.Find("Deck");
     OpponentDeckGO = GameObject.Find("OpponentDeck");
 }
Example #20
0
    public void SetText(string text, float textStretch)
    {
        Canvas canvas = transform.GetChild(0).GetComponent <Canvas>();

        TMPro.TextMeshProUGUI textMesh = canvas.transform.GetChild(0).GetComponent <TMPro.TextMeshProUGUI>();
        textMesh.SetText(text);
        textMesh.transform.localScale = new Vector3(textStretch, 1.0f, 1.0f);
    }
Example #21
0
 // Start is called before the first frame update
 void Start()
 {
     _CrystalsUI   = gameObject.transform.Find("Minerals").gameObject;
     _HealthUI     = gameObject.transform.Find("Health").gameObject;
     _crystalsText = _CrystalsUI.transform.Find("Cnt").gameObject.GetComponent <TMPro.TextMeshProUGUI>();
     _healthText   = _HealthUI.transform.Find("Cnt").gameObject.GetComponent <TMPro.TextMeshProUGUI>();
     _playerItems  = FindObjectOfType <PlayerItems>();
 }
Example #22
0
    // Use this for initialization
    void Start()
    {
        // songListImporter = GetComponent<SongList>();
        titleTextBox      = GetComponent <TMPro.TextMeshProUGUI>();
        titleTextBox.text = "title";

        //titleTextBox.text = SongList.Song;
    }
Example #23
0
    void RecalculateText()
    {
        if (TextComponent == null)
        {
            TextComponent = this.transform.Find("Text").GetComponent <TMPro.TextMeshProUGUI>();
        }
        if (RectTransform == null)
        {
            RectTransform = GetComponent <RectTransform>();
        }
        TextComponent.text = Text;
        Vector3[] vertices;
        TextComponent.ForceMeshUpdate();
        float textWidth = TextComponent.preferredWidth + Padding * 2;

        this.RectTransform.sizeDelta = new Vector3(textWidth, this.RectTransform.sizeDelta.y, 0f);
        TextComponent.ForceMeshUpdate();

        TMP_TextInfo textInfo       = TextComponent.textInfo;
        int          characterCount = textInfo.characterCount;

        if (characterCount == 0)
        {
            return;
        }

        float boundsMinX = TextComponent.bounds.min.x - Padding;
        float boundsMaxX = TextComponent.bounds.max.x + Padding;

        float fullWidth = textWidth + Padding * 2;
        float angle     = Angle * 100 / textWidth;

        for (int i = 0; i < characterCount; i++)
        {
            if (!textInfo.characterInfo[i].isVisible)
            {
                continue;
            }

            int vertexIndex   = textInfo.characterInfo[i].vertexIndex;
            int materialIndex = textInfo.characterInfo[i].materialReferenceIndex;
            vertices = textInfo.meshInfo[materialIndex].vertices;

            Vector3 charMidBaselinePos = new Vector2((vertices[vertexIndex + 0].x + vertices[vertexIndex + 2].x) / 2, textInfo.characterInfo[i].baseLine);

            float zeroToOnePos = (charMidBaselinePos.x - boundsMinX) / (boundsMaxX - boundsMinX);

            var quat = Quaternion.AngleAxis((zeroToOnePos - 0.5f) * angle, new Vector3(0f, 0f, -1f));
            vertices[vertexIndex + 0] = quat * vertices[vertexIndex + 0];
            vertices[vertexIndex + 1] = quat * vertices[vertexIndex + 1];
            vertices[vertexIndex + 2] = quat * vertices[vertexIndex + 2];
            vertices[vertexIndex + 3] = quat * vertices[vertexIndex + 3];
        }

        TextComponent.UpdateVertexData();
        SetVerticesDirty();
        SetMaterialDirty();
    }
        /// <inheritdoc />
        public override void Init(GameObject host, ThemeDefinition settings)
        {
            mesh        = host.GetComponent <TextMesh>();
            text        = host.GetComponent <Text>();
            meshPro     = host.GetComponent <TextMeshPro>();
            meshProUGUI = host.GetComponent <TextMeshProUGUI>();

            base.Init(host, settings);
        }
Example #25
0
    public void SaveSettings()
    {
        // Save the inputs to the variables from the networkmanager

        networkManager.ServerIP  = Settings_InputField_ServerURL.text.Remove(Settings_InputField_ServerURL.text.Length - 1, 1);
        networkManager.ServerPHP = Settings_InputField_ServerPHP.text.Remove(Settings_InputField_ServerPHP.text.Length - 1, 1);
        SettingsSavedText.SetActive(true);
        TMPro.TextMeshProUGUI text = SettingsSavedText.GetComponent <TMPro.TextMeshProUGUI>();
        text.text = "Server URL: '" + networkManager.ServerIP + "/" + networkManager.ServerPHP + "' saved!";
    }
Example #26
0
    void Start()
    {
        animator           = GetComponent <Animator>();
        currentDesperation = startingDesperation;
        currentMoney       = startingMoney;
        moneyText          = moneyTextObject.GetComponent <TMPro.TextMeshProUGUI>();
        moneyText.text     = "$" + startingMoney.ToString();

        twitterScript = GameObject.Find("UI/TwitterScriptObject").GetComponent <TwitterScript>();
    }
Example #27
0
 private void Awake()
 {
     PlayerArray[0].setPlayerNumber(1);
     PlayerArray[1].setPlayerNumber(2);
     Instance       = this;
     cam            = Camera.main;
     originalCamPos = cam.transform.position;
     players        = FindObjectsOfType <PlayerInput>();
     fadeInOutImage = GameObject.Find("FadeInOutImage").GetComponent <Image>();
     uIRoomText     = GameObject.Find("UIRoomText").GetComponent <TMPro.TextMeshProUGUI>();
 }
Example #28
0
    void Awake() {
        m_textRectTransform = MarqueeText.GetComponent<RectTransform>();
        MarqueeText.text = message;

        cloneObject = Instantiate(MarqueeText) as TextMeshProUGUI;
        RectTransform cloneRectTransform = cloneObject.GetComponent<RectTransform>();
        cloneRectTransform.SetParent(m_textRectTransform);
        //m_textRectTransform.position = new Vector3(MarqueeText.preferredWidth, 0, 0);
        cloneRectTransform.anchorMin = new Vector2(1, 0.5f);
        cloneRectTransform.localScale = new Vector3(1, 1, 1);
    }
Example #29
0
    IEnumerator Erase(TMPro.TextMeshProUGUI toProcess)
    {
        string current = toProcess.text;

        for (int i = current.Length; i >= 0; i--)
        {
            toProcess.text = current.Substring(0, i);
            yield return(new WaitForSeconds(typeSpeed));
        }
        toProcess.color = Color.clear;
    }
Example #30
0
 // Update is called once per frame
 void Update()
 {
     TMPro.TextMeshProUGUI myText = GetComponent <TextMeshProUGUI>();
     if (Input.GetKeyDown("space"))
     {
         myText.SetText("Hello World! My name is Alejandro");
     }
     if (Input.GetKeyDown(KeyCode.Escape))
     {
         Application.Quit();
     }
 }
Example #31
0
    public void SetSceneList()
    {
        Transform[] childList = ListBar.transform.GetComponentsInChildren <Transform>();
        for (int i = 1; i < childList.Length; i++)
        {
            Destroy(childList[i].gameObject);
        }
        ListBar.sizeDelta = Vector2.zero;

        string[] filters    = new[] { "*.json" };
        string[] ScenePaths = filters.SelectMany(f => System.IO.Directory.GetFiles(Application.dataPath + "/Resources/Data/Scene/", f)).ToArray();


        selectedIndex = -1;
        ListSelectedCursor.gameObject.SetActive(false);

        for (int i = 0; i < ScenePaths.Length; i++)
        {
            GameObject gameObject = Instantiate(infoBox, ListBar);

            TMPro.TextMeshProUGUI TMP = gameObject.transform.Find("Name").GetComponent <TMPro.TextMeshProUGUI>();
            TMP.gameObject.SetActive(true);
            TMP.text = Path.GetFileNameWithoutExtension(ScenePaths[i]);

            // Image image = gameObject.transform.Find("Image").GetComponent<Image>();
            // image.sprite = Units[i].Sprite;

            RectTransform rectTransform = gameObject.GetComponent <RectTransform>();
            rectTransform.sizeDelta = new Vector2(150, 150);
            ListBar.sizeDelta       = ListBar.rect.size + new Vector2(150, 0);

            Button button = gameObject.GetComponent <Button>();

            Image Background = gameObject.GetComponent <Image>();
            Color oldColor   = Background.color;

            int temp = i;

            button.onClick.AddListener(() =>
            {
                if (selectedIndex == temp)
                {
                    SetCursor(-1);
                }
                else
                {
                    SetCursor(temp);
                    Common.Data.LoadScene(ScenePaths[temp]);
                    inputField.text = Path.GetFileNameWithoutExtension(ScenePaths[temp]);
                }
            });
        }
    }
Example #32
0
 void Start()
 {
     plasticBagScore     = plasticBagScore.GetComponent <TMPro.TextMeshProUGUI>();
     plasticBottleScore  = plasticBottleScore.GetComponent <TMPro.TextMeshProUGUI>();
     plasticBagNumber    = plasticBagNumber.GetComponent <TMPro.TextMeshProUGUI>();
     plasticBottleNumber = plasticBottleNumber.GetComponent <TMPro.TextMeshProUGUI>();
     timeNumber          = timeNumber.GetComponent <TMPro.TextMeshProUGUI>();
     timeScore           = timeScore.GetComponent <TMPro.TextMeshProUGUI>();
     scoreText           = scoreText.GetComponent <TMPro.TextMeshProUGUI>();
     glassBottleScore    = glassBottleScore.GetComponent <TMPro.TextMeshProUGUI>();
     glassBottleNumber   = glassBottleNumber.GetComponent <TMPro.TextMeshProUGUI>();
     time = time.GetComponent <TMPro.TextMeshProUGUI>();
 }
        void OnEnable()
        {
            if (m_TextMeshPro == null) m_TextMeshPro = gameObject.GetComponent<TextMeshPro>();
            if (m_TextMeshProUI == null) m_TextMeshProUI = gameObject.GetComponent<TextMeshProUGUI>();
                      
            m_uiVertex = new UIVertex[4];
            
#if UNITY_EDITOR
            TMPro_EventManager.SPRITE_ASSET_PROPERTY_EVENT.Add(ON_SPRITE_ASSET_PROPERTY_CHANGED);
#endif

            LoadSpriteAsset(m_spriteAsset);
        }
Example #34
0
 public void GameOver()
 {
     TMPro.TextMeshProUGUI ScoreText     = EndMenuPanel.transform.Find("ScoreText").GetComponent <TMPro.TextMeshProUGUI>();
     TMPro.TextMeshProUGUI HighscoreText = EndMenuPanel.transform.Find("HighscoreText").GetComponent <TMPro.TextMeshProUGUI>();
     if (Score > HighScore)
     {
         HighScore = Score;
     }
     ScoreText.SetText("Your Score: " + Score);
     HighscoreText.SetText("Highscore: " + HighScore);
     EndMenuPanel.SetActive(true);
     Time.timeScale = 0;
 }
Example #35
0
 // Update is called once per frame
 void Update()
 {
     TMPro.TextMeshProUGUI myText = GetComponent <TextMeshProUGUI>();
     if (Input.GetKeyDown("space"))
     {
         myText.SetText("Hello World from Victoria Tinsley!");
         Debug.Log("Key Pressed");
     }
     if (Input.GetKeyDown(KeyCode.Escape))
     {
         Application.Quit();
     }
 }
Example #36
0
    public void SetTileList()
    {
        Transform[] childList = ListBar.transform.GetComponentsInChildren <Transform>();
        for (int i = 1; i < childList.Length; i++)
        {
            Destroy(childList[i].gameObject);
        }
        ListBar.sizeDelta = Vector2.zero;

        var Tiles = Common.Data.AllTiles;

        selectedIndex = -1;
        ListSelectedCursor.gameObject.SetActive(false);

        for (int i = 0; i < Tiles.Count; i++)
        {
            GameObject gameObject = Instantiate(infoBox, ListBar);

            TMPro.TextMeshProUGUI TMP = gameObject.transform.Find("Name").GetComponent <TMPro.TextMeshProUGUI>();
            TMP.gameObject.SetActive(true);
            TMP.text = Tiles[i].Name;

            Image image = gameObject.transform.Find("Image").GetComponent <Image>();
            image.sprite = Tiles[i].Sprite;


            RectTransform rectTransform = gameObject.GetComponent <RectTransform>();
            rectTransform.sizeDelta = new Vector2(150, 150);
            ListBar.sizeDelta       = ListBar.rect.size + new Vector2(150, 0);

            Button button = gameObject.GetComponent <Button>();

            Image Background = gameObject.GetComponent <Image>();
            Color oldColor   = Background.color;

            int temp = i;

            button.onClick.AddListener(() =>
            {
                if (selectedIndex == temp)
                {
                    SetCursor(-1);
                }
                else
                {
                    SetCursor(temp);
                    selectedObject = Tiles[temp];
                }
            });
        }
    }
Example #37
0
    /// <summary>
    /// Creates the Predictive Text Object as the last sibling
    /// </summary>
    private void CreatePredictionObject()
    {
        // Create Prediction Object
        GameObject predictionGO = Instantiate(_inputText.gameObject, _inputText.transform.parent);

        predictionGO.transform.SetAsLastSibling();
        predictionGO.name = "TXT_Prediction";
        _predictionText   = predictionGO.GetComponent <TMPro.TextMeshProUGUI>();
        SetPredictionText("");
        _predictionTransform  = (RectTransform)predictionGO.transform;
        _predictionText.color = _predictionTextColour;

        // Update its position
        UpdatePredictionObjectOffset();

        // Calculate Max Prediction Items our root can hold.
        RectTransform itemRect = _predictionItemTemplate.transform as RectTransform;

        if (itemRect != null)
        {
            float itemSize = itemRect.sizeDelta.y;

            float rootSize = _predictionItemRoot.rect.size.y;

            int maxItems = Mathf.FloorToInt(rootSize / itemSize);

            _predictionItems    = new List <PredictionItem>(maxItems);
            _predictionCommands = new List <ICommand>(maxItems + 1);
            for (int i = 0; i < maxItems; ++i)
            {
                PredictionItem item = Instantiate(_predictionItemTemplate, _predictionItemRoot);

                Color color  = KDebug.GetVisualData.PrimaryColor;
                bool  IsEven = i % 2 == 0;
                float alpha  = IsEven ? 0.85f : 1f;
                color.a = alpha;

                item.BaseColor   = color;
                item.Image.color = item.BaseColor;
                item.Text.color  = KDebug.GetVisualData.PrimaryTextColor;

                item.gameObject.SetActive(true);
                _predictionItems.Add(item);
            }
        }
        else
        {
            _predictionCommands = new List <ICommand>(3);
            throw new NullReferenceException("Item Rect is null!");
        }
    }
Example #38
0
        void OnEnable()
        {
            if (m_TextMeshPro == null) m_TextMeshPro = gameObject.GetComponent<TextMeshPro>();
            if (m_TextMeshProUI == null) m_TextMeshProUI = gameObject.GetComponent<TextMeshProUGUI>();
                      
            m_uiVertex = new UIVertex[4];
            
#if UNITY_EDITOR
            TMPro_EventManager.SPRITE_ASSET_PROPERTY_EVENT += ON_SPRITE_ASSET_PROPERTY_CHANGED;
#endif

            LoadSpriteAsset(m_spriteAsset);

            //m_inlineGraphic.material.renderQueue = 3000;
                
        }
    void Awake()
    {
        // Get Reference to TextMeshPro Component if one exists; Otherwise add one.
        m_textMeshPro = gameObject.GetComponent<TextMeshProUGUI>() ?? gameObject.AddComponent<TextMeshProUGUI>();
        m_textMeshPro.text = label01;
        m_textMeshPro.enableWordWrapping = true;
        m_textMeshPro.alignment = TextAlignmentOptions.Top;

        if (GetComponentInParent(typeof(Canvas)) as Canvas == null)
        {
            GameObject canvas = new GameObject("Canvas", typeof(Canvas));
            gameObject.transform.SetParent(canvas.transform);
            canvas.GetComponent<Canvas>().renderMode = RenderMode.ScreenSpaceOverlay;

            // Set RectTransform Size
            gameObject.GetComponent<RectTransform>().sizeDelta = new Vector2(500, 300);
            m_textMeshPro.fontSize = 48;
        }
    }
Example #40
0
        /// <summary>
        /// Function to find the nearest character to position.
        /// </summary>
        /// <param name="text">A reference to the TextMeshPro UGUI component.</param>
        /// <param name="position">Position to check for intersection.</param>
        /// <param name="camera"></param>
        /// <param name="visibleOnly">Only check for visible characters.</param>
        /// <returns></returns>
        public static int FindNearestCharacter(TextMeshProUGUI text, Vector3 position, Camera camera, bool visibleOnly)
        {
            RectTransform rectTransform = text.rectTransform;

            float distanceSqr = Mathf.Infinity;
            int closest = 0;

            // Convert position into Worldspace coordinates
            ScreenPointToWorldPointInRectangle(rectTransform, position, camera, out position);

            for (int i = 0; i < text.textInfo.characterCount; i++)
            {
                // Get current character info.
                TMP_CharacterInfo cInfo = text.textInfo.characterInfo[i];
                if (visibleOnly && !cInfo.isVisible)
                    continue;

                // Get Bottom Left and Top Right position of the current character
                Vector3 bl = rectTransform.TransformPoint(cInfo.bottomLeft);
                Vector3 tl = rectTransform.TransformPoint(new Vector3(cInfo.bottomLeft.x, cInfo.topRight.y, 0));
                Vector3 tr = rectTransform.TransformPoint(cInfo.topRight);
                Vector3 br = rectTransform.TransformPoint(new Vector3(cInfo.topRight.x, cInfo.bottomLeft.y, 0));

                if (PointIntersectRectangle(position, bl, tl, tr, br))
                    return i;

                // Find the closest corner to position.
                float dbl = DistanceToLine(bl, tl, position);
                float dtl = DistanceToLine(tl, tr, position);
                float dtr = DistanceToLine(tr, br, position);
                float dbr = DistanceToLine(br, bl, position);

                float d = dbl < dtl ? dbl : dtl;
                d = d < dtr ? d : dtr;
                d = d < dbr ? d : dbr;

                if (distanceSqr > d)
                {
                    distanceSqr = d;
                    closest = i;
                }
            }

            //Debug.Log("Returning nearest character at index: " + closest);

            return closest;
        }
Example #41
0
        /// <summary>
        /// Function returning the index of the word at the given position (if any).
        /// </summary>
        /// <param name="text">A reference to the TextMeshPro UGUI component.</param>
        /// <param name="position"></param>
        /// <param name="camera"></param>
        /// <returns></returns>
        public static int FindNearestLink(TextMeshProUGUI text, Vector3 position, Camera camera)
        {
            RectTransform rectTransform = text.rectTransform;

            // Convert position into Worldspace coordinates
            ScreenPointToWorldPointInRectangle(rectTransform, position, camera, out position);

            float distanceSqr = Mathf.Infinity;
            int closest = 0;

            for (int i = 0; i < text.textInfo.linkCount; i++)
            {
                TMP_LinkInfo linkInfo = text.textInfo.linkInfo[i];

                bool isBeginRegion = false;

                Vector3 bl = Vector3.zero;
                Vector3 tl = Vector3.zero;
                Vector3 br = Vector3.zero;
                Vector3 tr = Vector3.zero;

                // Iterate through each character of the word
                for (int j = 0; j < linkInfo.linkTextLength; j++)
                {
                    int characterIndex = linkInfo.linkTextfirstCharacterIndex + j;
                    TMP_CharacterInfo currentCharInfo = text.textInfo.characterInfo[characterIndex];
                    int currentLine = currentCharInfo.lineNumber;

                    if (isBeginRegion == false)
                    {
                        isBeginRegion = true;

                        bl = rectTransform.TransformPoint(new Vector3(currentCharInfo.bottomLeft.x, currentCharInfo.descender, 0));
                        tl = rectTransform.TransformPoint(new Vector3(currentCharInfo.bottomLeft.x, currentCharInfo.ascender, 0));

                        //Debug.Log("Start Word Region at [" + currentCharInfo.character + "]");

                        // If Word is one character
                        if (linkInfo.linkTextLength == 1)
                        {
                            isBeginRegion = false;

                            br = rectTransform.TransformPoint(new Vector3(currentCharInfo.topRight.x, currentCharInfo.descender, 0));
                            tr = rectTransform.TransformPoint(new Vector3(currentCharInfo.topRight.x, currentCharInfo.ascender, 0));

                            // Check for Intersection
                            if (PointIntersectRectangle(position, bl, tl, tr, br))
                                return i;

                            //Debug.Log("End Word Region at [" + currentCharInfo.character + "]");
                        }
                    }

                    // Last Character of Word
                    if (isBeginRegion && j == linkInfo.linkTextLength - 1)
                    {
                        isBeginRegion = false;

                        br = rectTransform.TransformPoint(new Vector3(currentCharInfo.topRight.x, currentCharInfo.descender, 0));
                        tr = rectTransform.TransformPoint(new Vector3(currentCharInfo.topRight.x, currentCharInfo.ascender, 0));

                        // Check for Intersection
                        if (PointIntersectRectangle(position, bl, tl, tr, br))
                            return i;

                        //Debug.Log("End Word Region at [" + currentCharInfo.character + "]");
                    }
                    // If Word is split on more than one line.
                    else if (isBeginRegion && currentLine != text.textInfo.characterInfo[characterIndex + 1].lineNumber)
                    {
                        isBeginRegion = false;

                        br = rectTransform.TransformPoint(new Vector3(currentCharInfo.topRight.x, currentCharInfo.descender, 0));
                        tr = rectTransform.TransformPoint(new Vector3(currentCharInfo.topRight.x, currentCharInfo.ascender, 0));

                        // Check for Intersection
                        if (PointIntersectRectangle(position, bl, tl, tr, br))
                            return i;

                        //Debug.Log("End Word Region at [" + currentCharInfo.character + "]");
                    }
                }

                // Find the closest line segment to position.
                float dbl = DistanceToLine(bl, tl, position); // (position - bl).sqrMagnitude;
                float dtl = DistanceToLine(tl, tr, position); // (position - tl).sqrMagnitude;
                float dtr = DistanceToLine(tr, br, position); // (position - tr).sqrMagnitude;
                float dbr = DistanceToLine(br, bl, position); // (position - br).sqrMagnitude;

                float d = dbl < dtl ? dbl : dtl;
                d = d < dtr ? d : dtr;
                d = d < dbr ? d : dbr;

                if (distanceSqr > d)
                {
                    distanceSqr = d;
                    closest = i;
                }
                //Debug.Log("Word at Index: " + i + " is located at (" + bl + ", " + tl + ", " + tr + ", " + br + ").");

            }

            return closest;
        }
Example #42
0
        /// <summary>
        /// Function returning the index of the Link at the given position (if any).
        /// </summary>
        /// <param name="text">A reference to the TextMeshPro UGUI component.</param>
        /// <param name="position"></param>
        /// <param name="camera"></param>
        /// <returns></returns>
        public static int FindIntersectingLink(TextMeshProUGUI text, Vector3 position, Camera camera)
        {
            Transform rectTransform = text.transform;

            // Convert position into Worldspace coordinates
            ScreenPointToWorldPointInRectangle(rectTransform, position, camera, out position);

            for (int i = 0; i < text.textInfo.linkCount; i++)
            {
                TMP_LinkInfo linkInfo = text.textInfo.linkInfo[i];

                bool isBeginRegion = false;

                Vector3 bl = Vector3.zero;
                Vector3 tl = Vector3.zero;
                Vector3 br = Vector3.zero;
                Vector3 tr = Vector3.zero;

                // Iterate through each character of the word
                for (int j = 0; j < linkInfo.linkTextLength; j++)
                {
                    int characterIndex = linkInfo.linkTextfirstCharacterIndex + j;
                    TMP_CharacterInfo currentCharInfo = text.textInfo.characterInfo[characterIndex];
                    int currentLine = currentCharInfo.lineNumber;

                    if (isBeginRegion == false)
                    {
                        isBeginRegion = true;

                        bl = rectTransform.TransformPoint(new Vector3(currentCharInfo.bottomLeft.x, currentCharInfo.descender, 0));
                        tl = rectTransform.TransformPoint(new Vector3(currentCharInfo.bottomLeft.x, currentCharInfo.ascender, 0));

                        //Debug.Log("Start Word Region at [" + currentCharInfo.character + "]");

                        // If Word is one character
                        if (linkInfo.linkTextLength == 1)
                        {
                            isBeginRegion = false;

                            br = rectTransform.TransformPoint(new Vector3(currentCharInfo.topRight.x, currentCharInfo.descender, 0));
                            tr = rectTransform.TransformPoint(new Vector3(currentCharInfo.topRight.x, currentCharInfo.ascender, 0));

                            // Check for Intersection
                            if (PointIntersectRectangle(position, bl, tl, tr, br))
                                return i;

                            //Debug.Log("End Word Region at [" + currentCharInfo.character + "]");
                        }
                    }

                    // Last Character of Word
                    if (isBeginRegion && j == linkInfo.linkTextLength - 1)
                    {
                        isBeginRegion = false;

                        br = rectTransform.TransformPoint(new Vector3(currentCharInfo.topRight.x, currentCharInfo.descender, 0));
                        tr = rectTransform.TransformPoint(new Vector3(currentCharInfo.topRight.x, currentCharInfo.ascender, 0));

                        // Check for Intersection
                        if (PointIntersectRectangle(position, bl, tl, tr, br))
                            return i;

                        //Debug.Log("End Word Region at [" + currentCharInfo.character + "]");
                    }
                    // If Word is split on more than one line.
                    else if (isBeginRegion && currentLine != text.textInfo.characterInfo[characterIndex + 1].lineNumber)
                    {
                        isBeginRegion = false;

                        br = rectTransform.TransformPoint(new Vector3(currentCharInfo.topRight.x, currentCharInfo.descender, 0));
                        tr = rectTransform.TransformPoint(new Vector3(currentCharInfo.topRight.x, currentCharInfo.ascender, 0));

                        // Check for Intersection
                        if (PointIntersectRectangle(position, bl, tl, tr, br))
                            return i;

                        //Debug.Log("End Word Region at [" + currentCharInfo.character + "]");
                    }
                }

                //Debug.Log("Word at Index: " + i + " is located at (" + bl + ", " + tl + ", " + tr + ", " + br + ").");

            }

            return -1;
        }
Example #43
0
    void OnApplicationFocus(bool focusStatus)
    {
        if(!focusStatus)
        {
            StopCoroutine("Resume");

            if(!touchStateIsSet)
            {
                touchState = controller.CanTouch;
                touchStateIsSet = true;
            }
            controller.CanTouch = false;

            if(pauseText != null) Destroy (pauseText.gameObject);
            pauseText = Instantiate (pausePrefab) as TextMeshProUGUI;
            pauseText.transform.SetParent(canvas.GetComponent<RectTransform>(), false);

            Time.timeScale = 0;
        }
        else
        {
            StartCoroutine("Resume");
        }
    }
        public void AddInlineGraphicsChild()
        {
            if (m_inlineGraphic != null)
            {
                //Debug.LogWarning("A child Inline Graphics object already exists.");
                return;
            }

            GameObject inlineGraphicObj = new GameObject("Inline Graphic");

            m_inlineGraphic = inlineGraphicObj.AddComponent<InlineGraphic>();

            m_inlineGraphicRectTransform = inlineGraphicObj.GetComponent<RectTransform>();
            m_inlineGraphicCanvasRenderer = inlineGraphicObj.GetComponent<CanvasRenderer>();

            m_inlineGraphicRectTransform.SetParent(transform, false);
            m_inlineGraphicRectTransform.localPosition = Vector3.zero;
            m_inlineGraphicRectTransform.anchoredPosition3D = Vector3.zero;
            m_inlineGraphicRectTransform.sizeDelta = Vector2.zero;
            m_inlineGraphicRectTransform.anchorMin = Vector2.zero;
            m_inlineGraphicRectTransform.anchorMax = Vector2.one;

            m_TextMeshPro = gameObject.GetComponent<TextMeshPro>();
            m_TextMeshProUI = gameObject.GetComponent<TextMeshProUGUI>();
        }
        private void Start()
        {
            SendCatToLaunchBay();

            Canvas canvas = LoadingScreen.Instance.GetComponentInChildren<Canvas>();
            
            status = CreateTextObject(canvas, "MMStatus");
            errors = CreateTextObject(canvas, "MMErrors");
            warning = CreateTextObject(canvas, "MMWarning");
            warning.text = "";

            //if (Versioning.version_major == 1 && Versioning.version_minor == 0 && Versioning.Revision == 5 && Versioning.BuildID == 1024)
            //{
            //    warning.text = "Your KSP 1.0.5 is running on build 1024. You should upgrade to build 1028 to avoid problems with addons.";
            //    //if (GUI.Button(new Rect(Screen.width / 2f - 100, offsetY, 200, 20), "Click to open the Forum thread"))
            //    //    Application.OpenURL("http://forum.kerbalspaceprogram.com/index.php?/topic/124998-silent-patch-for-ksp-105-published/");
            //}
        }
 private static void SetDefaultTextValues(TextMeshProUGUI lbl)
 {
     // Set text values we want across UI elements in default controls.
     // Don't set values which are the same as the default values for the Text component,
     // since there's no point in that, and it's good to keep them as consistent as possible.
     lbl.color = s_TextColor;
     lbl.fontSize = 14;
 }
Example #47
0
    public virtual void GenerateTextComponent()
    {
        textGUI = gameObject.AddComponent<TextMeshProUGUI> ();
        textGUI.font = GetFont(font);
        textGUI.enableWordWrapping = enableWordWrapping;
        textGUI.richText = true;
        if(fontStyle != null){
            textGUI.fontStyle = (FontStyles)Enum.Parse (typeof(FontStyles), fontStyle);
        }
        textGUI.fontSize = fontSize;
        textGUI.OverflowMode = overflowMode;
        //textGUI.extraPadding = true;

        if (maxVisibleLines > 0) {
            textGUI.maxVisibleLines = maxVisibleLines;
        }
        textGUI.enableAutoSizing = sizeToFit;
        textGUI.lineSpacing = lineSpacing;
        textGUI.fontSizeMin = minSize;
        textGUI.fontSizeMax = maxSize;

        //public enum TextAlignmentOptions { TopLeft = 0, Top = 1, TopRight = 2, TopJustified = 3, Left = 4, Center = 5, Right = 6, Justified = 7, BottomLeft = 8, Bottom = 9, BottomRight = 10, BottomJustified = 11, BaselineLeft = 12, Baseline = 13, BaselineRight = 14, BaselineJustified = 15 };
        textGUI.alignment = alignment;

        textGUI.color = fontColor;
        textGUI.text = PlanetUnityStyle.ReplaceStyleTags(value);
    }
Example #48
0
    void Awake()
    {
        controller = transform.parent.GetComponentInChildren<Controller>();
        purchaseManager = transform.parent.FindChild("SOOMLA").GetComponent<PurchaseManager>();
        frogPackages = GetComponentInParent<FrogPackages>();
        variableManager = GetComponentInParent<VariableManager>();
        advertisingManager = GetComponentInParent<AdvertisingManager>();
        canvas = GetComponent<RectTransform>();
        titleTransform = canvas.FindChild("Title").GetComponent<RectTransform>();

        mainMenu = canvas.FindChild("MainMenu").GetComponent<CanvasGroup>();
        frogButton = mainMenu.transform.FindChild("FrogButton").GetComponent<RectTransform>();
        settingsButton = mainMenu.transform.FindChild("SettingsButton").GetComponent<RectTransform>();

        settingsMenu = canvas.FindChild("SettingsPanel").GetComponent<CanvasGroup>();
        musicToggle = settingsMenu.transform.GetChild(0).FindChild("MusicToggle").GetComponent<Toggle>();

        hud = transform.FindChild("HUD").GetComponent<HUD>();
        hudCanvas = hud.GetComponent<CanvasGroup>();
        hudRect = hud.GetComponent<RectTransform>();

        qualityCountPanelCG = canvas.FindChild("QualityCountPanel").GetComponent<CanvasGroup>();
        qualityCountPanel = qualityCountPanelCG.GetComponent<RectTransform>();
        perfectCount = qualityCountPanel.FindChild("PerfectCount").GetComponent<TextMeshProUGUI>();
        greatCount = qualityCountPanel.FindChild("GreatCount").GetComponent<TextMeshProUGUI>();;
        okCount = qualityCountPanel.FindChild("OKCount").GetComponent<TextMeshProUGUI>();;

        flyIconPosition = new Vector2(screenWidth, 50);
        flyButton = canvas.FindChild ("FlyPanel").GetComponent<Button>();
        flyPanelCG = flyButton.GetComponent<CanvasGroup>();
        flyTextAnimator = flyButton.transform.FindChild("FlyCount").GetComponent<Animator>();
        flyCount = flyButton.transform.FindChild("FlyCount").GetComponent<TextMeshProUGUI>();
        flyToGoText = flyButton.transform.FindChild("ToGoText").GetComponent<TextMeshProUGUI>();
        tameFlyNet = Instantiate(tameFlyNetPrefab, flyIconPosition, Quaternion.identity) as GameObject;

        arrowPanelCG = canvas.FindChild("ArrowPanel").GetComponent<CanvasGroup>();
        arrowPanel = arrowPanelCG.GetComponent<RectTransform>();
        frogName = arrowPanel.FindChild("FrogName").GetComponent<TextMeshProUGUI>();
        arrowPanelBuyButton = arrowPanel.FindChild("BuyButton").gameObject;

        returnPanel = canvas.FindChild("ReturnPanel").GetComponent<CanvasGroup>();
        returnButton = returnPanel.transform.FindChild("ReturnButton").GetComponent<RectTransform>();

        Transform endGameTransform = canvas.FindChild("EndGamePanel");
        endGamePanel = endGameTransform.GetComponent<CanvasGroup>();
        giftButton = endGameTransform.FindChild("GiftsButton").gameObject;
        adButton = endGameTransform.FindChild("AdsButton").gameObject;

        timeUntilGiftText = endGameTransform.FindChild("TimeUntilGift").GetComponent<TextMeshProUGUI>();

        buyButtonObject = endGameTransform.FindChild("BuyButton").gameObject;
        buyButton = buyButtonObject.GetComponent<Button>();
        buyButtonText = buyButton.transform.FindChild("Text").GetComponent<TextMeshProUGUI>();
        buyButtonImage = buyButton.transform.FindChild("Image").GetComponent<Image>();
    }
 public static void ON_TEXTMESHPRO_UGUI_PROPERTY_CHANGED(bool isChanged, TextMeshProUGUI obj)
 {
     if (TEXTMESHPRO_UGUI_PROPERTY_EVENT != null)
         TEXTMESHPRO_UGUI_PROPERTY_EVENT(isChanged, obj);
 }
Example #50
0
 internal void init()
 {
     endTurnButton.onClick.AddListener(() => onClick());
     buttonText = endTurnButton.GetComponentInChildren<TextMeshProUGUI>();
     buttonBg = endTurnButton.GetComponent<SVGImage>();
 }
 public static void ON_TEXTMESHPRO_UGUI_PROPERTY_CHANGED(bool isChanged, TextMeshProUGUI obj)
 {
     TEXTMESHPRO_UGUI_PROPERTY_EVENT.Call(isChanged, obj);
 }
        /// <summary>
        /// Function to add a new sub text object.
        /// </summary>
        /// <param name="textComponent"></param>
        /// <param name="materialReference"></param>
        /// <returns></returns>
        public static TMP_SubMeshUI AddSubTextObject(TextMeshProUGUI textComponent, MaterialReference materialReference)
        {
            GameObject go = new GameObject("TMP UI SubObject [" + materialReference.material.name + "]");

            go.transform.SetParent(textComponent.transform, false);

            RectTransform rectTransform = go.AddComponent<RectTransform>();
            rectTransform.anchorMin = Vector2.zero;
            rectTransform.anchorMax = Vector2.one;
            rectTransform.sizeDelta = Vector2.zero;
            rectTransform.pivot = textComponent.rectTransform.pivot;

            TMP_SubMeshUI subMesh = go.AddComponent<TMP_SubMeshUI>();

            subMesh.m_canvasRenderer = subMesh.canvasRenderer;
            subMesh.m_TextComponent = textComponent;

            subMesh.m_materialReferenceIndex = materialReference.index;
            subMesh.m_fontAsset = materialReference.fontAsset;
            subMesh.m_spriteAsset = materialReference.spriteAsset;
            subMesh.m_isDefaultMaterial = materialReference.isDefaultMaterial;
            subMesh.SetSharedMaterial(materialReference.material);

            return subMesh;
        }
Example #53
0
 internal void init()
 {
     serverText = GetComponent<TextMeshProUGUI>();
 }
        void Awake()
        {
            // Make sure this component is attached to an object which contains a TextMeshPro or TextMeshPro UI Component.
            if (gameObject.GetComponent<TextMeshPro>() == null && gameObject.GetComponent<TextMeshProUGUI>() == null)
                Debug.LogWarning("The InlineGraphics Component must be attached to a TextMesh Pro Object");

            // Add a Child GameObject to the TextMeshPro Object if one is not already present.
            if (m_inlineGraphic == null)
            {
                GameObject inlineGraphicObj = new GameObject("Inline Graphic");

                m_inlineGraphic = inlineGraphicObj.AddComponent<InlineGraphic>();

                m_inlineGraphicRectTransform = inlineGraphicObj.GetComponent<RectTransform>();
                m_inlineGraphicCanvasRenderer = inlineGraphicObj.GetComponent<CanvasRenderer>();

                m_inlineGraphicRectTransform.SetParent(transform, false);
                m_inlineGraphicRectTransform.localPosition = Vector3.zero;
                m_inlineGraphicRectTransform.anchoredPosition3D = Vector3.zero;
                m_inlineGraphicRectTransform.sizeDelta = Vector2.zero;
                m_inlineGraphicRectTransform.anchorMin = Vector2.zero;
                m_inlineGraphicRectTransform.anchorMax = Vector2.one;

                m_TextMeshPro = gameObject.GetComponent<TextMeshPro>();
                m_TextMeshProUI = gameObject.GetComponent<TextMeshProUGUI>();
            }
        }
Example #55
0
 // Event received when UNDO / REDO Event alters the properties of the object.
 void ON_TEXTMESHPRO_UGUI_PROPERTY_CHANGED(bool isChanged, TextMeshProUGUI obj)
 {
     //Debug.Log("Event Received by " + obj);
     
     if (obj == this)
     {
         //Debug.Log("Undo / Redo Event Received by Object ID:" + GetInstanceID());
         m_havePropertiesChanged = true;
         isInputParsingRequired = true;
         /* ScheduleUpdate(); */
     }
 }
Example #56
0
        // WORD HANDLING

        /// <summary>
        /// Function returning the index of the word at the given position (if any).
        /// </summary>
        /// <param name="text">A reference to the TextMeshPro UGUI component.</param>
        /// <param name="position"></param>
        /// <param name="camera"></param>
        /// <returns></returns>
        public static int FindIntersectingWord(TextMeshProUGUI text, Vector3 position, Camera camera)
        {
            RectTransform rectTransform = text.rectTransform;

            // Convert position into Worldspace coordinates
            ScreenPointToWorldPointInRectangle(rectTransform, position, camera, out position);

            for (int i = 0; i < text.textInfo.wordCount; i++)
            {
                TMP_WordInfo wInfo = text.textInfo.wordInfo[i];

                bool isBeginRegion = false;

                Vector3 bl = Vector3.zero;
                Vector3 tl = Vector3.zero;
                Vector3 br = Vector3.zero;
                Vector3 tr = Vector3.zero;

                float maxAscender = -Mathf.Infinity;
                float minDescender = Mathf.Infinity;

                // Iterate through each character of the word
                for (int j = 0; j < wInfo.characterCount; j++)
                {
                    int characterIndex = wInfo.firstCharacterIndex + j;
                    TMP_CharacterInfo currentCharInfo = text.textInfo.characterInfo[characterIndex];
                    int currentLine = currentCharInfo.lineNumber;

                    bool isCharacterVisible = characterIndex > text.maxVisibleCharacters ||
                                              currentCharInfo.lineNumber > text.maxVisibleLines ||
                                             (text.OverflowMode == TextOverflowModes.Page && currentCharInfo.pageNumber + 1 != text.pageToDisplay) ? false : true;

                    // Track maximum Ascender and minimum Descender for each word.
                    maxAscender = Mathf.Max(maxAscender, currentCharInfo.ascender);
                    minDescender = Mathf.Min(minDescender, currentCharInfo.descender);

                    if (isBeginRegion == false && isCharacterVisible)
                    {
                        isBeginRegion = true;

                        bl = new Vector3(currentCharInfo.bottomLeft.x, currentCharInfo.descender, 0);
                        tl = new Vector3(currentCharInfo.bottomLeft.x, currentCharInfo.ascender, 0);

                        //Debug.Log("Start Word Region at [" + currentCharInfo.character + "]");

                        // If Word is one character
                        if (wInfo.characterCount == 1)
                        {
                            isBeginRegion = false;

                            br = new Vector3(currentCharInfo.topRight.x, currentCharInfo.descender, 0);
                            tr = new Vector3(currentCharInfo.topRight.x, currentCharInfo.ascender, 0);

                            // Transform coordinates to be relative to transform and account min descender and max ascender.
                            bl = rectTransform.TransformPoint(new Vector3(bl.x, minDescender, 0));
                            tl = rectTransform.TransformPoint(new Vector3(tl.x, maxAscender, 0));
                            tr = rectTransform.TransformPoint(new Vector3(tr.x, maxAscender, 0));
                            br = rectTransform.TransformPoint(new Vector3(br.x, minDescender, 0));

                            // Check for Intersection
                            if (PointIntersectRectangle(position, bl, tl, tr, br))
                                return i;

                            //Debug.Log("End Word Region at [" + currentCharInfo.character + "]");
                        }
                    }

                    // Last Character of Word
                    if (isBeginRegion && j == wInfo.characterCount - 1)
                    {
                        isBeginRegion = false;

                        br = new Vector3(currentCharInfo.topRight.x, currentCharInfo.descender, 0);
                        tr = new Vector3(currentCharInfo.topRight.x, currentCharInfo.ascender, 0);

                        // Transform coordinates to be relative to transform and account min descender and max ascender.
                        bl = rectTransform.TransformPoint(new Vector3(bl.x, minDescender, 0));
                        tl = rectTransform.TransformPoint(new Vector3(tl.x, maxAscender, 0));
                        tr = rectTransform.TransformPoint(new Vector3(tr.x, maxAscender, 0));
                        br = rectTransform.TransformPoint(new Vector3(br.x, minDescender, 0));

                        // Check for Intersection
                        if (PointIntersectRectangle(position, bl, tl, tr, br))
                            return i;

                        //Debug.Log("End Word Region at [" + currentCharInfo.character + "]");
                    }
                    // If Word is split on more than one line.
                    else if (isBeginRegion && currentLine != text.textInfo.characterInfo[characterIndex + 1].lineNumber)
                    {
                        isBeginRegion = false;

                        br = new Vector3(currentCharInfo.topRight.x, currentCharInfo.descender, 0);
                        tr = new Vector3(currentCharInfo.topRight.x, currentCharInfo.ascender, 0);

                        // Transform coordinates to be relative to transform and account min descender and max ascender.
                        bl = rectTransform.TransformPoint(new Vector3(bl.x, minDescender, 0));
                        tl = rectTransform.TransformPoint(new Vector3(tl.x, maxAscender, 0));
                        tr = rectTransform.TransformPoint(new Vector3(tr.x, maxAscender, 0));
                        br = rectTransform.TransformPoint(new Vector3(br.x, minDescender, 0));

                        maxAscender = -Mathf.Infinity;
                        minDescender = Mathf.Infinity;

                        // Check for Intersection
                        if (PointIntersectRectangle(position, bl, tl, tr, br))
                            return i;

                        //Debug.Log("End Word Region at [" + currentCharInfo.character + "]");
                    }
                }

                //Debug.Log("Word at Index: " + i + " is located at (" + bl + ", " + tl + ", " + tr + ", " + br + ").");

            }

            return -1;
        }
        // Event received when custom material editor properties are changed.
        void ON_MATERIAL_PROPERTY_CHANGED(bool isChanged, Material mat)
        {
            //Debug.Log("*** ON_MATERIAL_PROPERTY_CHANGED ***");

            int targetMaterialID = mat.GetInstanceID();
            int sharedMaterialID = m_sharedMaterial.GetInstanceID();
            int maskingMaterialID = m_MaskMaterial == null ? 0 : m_MaskMaterial.GetInstanceID();

            // Filter events and return if the affected material is not this object's material.
            //if (targetMaterialID != sharedMaterialID && targetMaterialID != maskingMaterialID) return;

            if (m_TextComponent == null) m_TextComponent = GetComponentInParent<TextMeshProUGUI>();

            // Make sure material properties are synchronized between the assigned material and masking material.
            if (m_MaskMaterial != null)
            {
                UnityEditor.Undo.RecordObject(m_MaskMaterial, "Material Property Changes");
                UnityEditor.Undo.RecordObject(m_sharedMaterial, "Material Property Changes");

                if (targetMaterialID == sharedMaterialID)
                {
                    //Debug.Log("Copy base material properties to masking material if not null.");
                    float stencilID = m_MaskMaterial.GetFloat(ShaderUtilities.ID_StencilID);
                    float stencilComp = m_MaskMaterial.GetFloat(ShaderUtilities.ID_StencilComp);
                    m_MaskMaterial.CopyPropertiesFromMaterial(mat);
                    m_MaskMaterial.shaderKeywords = mat.shaderKeywords;

                    m_MaskMaterial.SetFloat(ShaderUtilities.ID_StencilID, stencilID);
                    m_MaskMaterial.SetFloat(ShaderUtilities.ID_StencilComp, stencilComp);
                }
                else if (targetMaterialID == maskingMaterialID)
                {
                    // Update the padding 
                    GetPaddingForMaterial(mat);

                    m_sharedMaterial.CopyPropertiesFromMaterial(mat);
                    m_sharedMaterial.shaderKeywords = mat.shaderKeywords;
                    m_sharedMaterial.SetFloat(ShaderUtilities.ID_StencilID, 0);
                    m_sharedMaterial.SetFloat(ShaderUtilities.ID_StencilComp, 8);
                }
            }

            m_padding = GetPaddingForMaterial();

            SetVerticesDirty();
            m_ShouldRecalculateStencil = true;
            RecalculateClipping();
            RecalculateMasking();
        }
Example #58
0
    void Initialize()
    {
        this.quizManager = this.GetComponent<QuizManager>();

        this.rightAnswerCount = 0;
        this.quizImage = GameObject.Find("QuizImage");

        this.answerText = new Text[2];
        this.answerText[0] = GameObject.Find("LeftAnswerText").GetComponent<Text>();
        this.answerText[1] = GameObject.Find("RightAnswerText").GetComponent<Text>();

        this.countText = GameObject.Find("CountText").GetComponent<TextMeshProUGUI>();
        this.timeText = GameObject.Find("TimeText").GetComponent<TextMeshProUGUI>();
        this.startPos = this.quizImage.transform.position;
        DOTween.Init(true, false, LogBehaviour.Default);//初期化

        this.stopWatch = this.GetComponent<StopWatch>();

        this.audioSource = this.GetComponent<AudioSource>();
    }
    IEnumerator Start()
    {
        if (BenchmarkType == 0) // TextMesh Pro Component
        {
            m_textMeshPro = gameObject.AddComponent<TextMeshProUGUI>();
            //m_textContainer = GetComponent<TextContainer>();

            //m_textMeshPro.anchorDampening = true;

            if (TMProFont != null)
                m_textMeshPro.font = TMProFont;

            //m_textMeshPro.font = Resources.Load("Fonts & Materials/IMPACT SDF", typeof(TextMeshProFont)) as TextMeshProFont; // Make sure the IMPACT SDF exists before calling this...
            //m_textMeshPro.fontSharedMaterial = Resources.Load("Fonts & Materials/IMPACT SDF", typeof(Material)) as Material; // Same as above make sure this material exists.

            m_textMeshPro.fontSize = 48;
            m_textMeshPro.alignment = TextAlignmentOptions.Center;
            //m_textMeshPro.anchor = AnchorPositions.Center;
            m_textMeshPro.extraPadding = true;
            //m_textMeshPro.outlineWidth = 0.25f;
            //m_textMeshPro.fontSharedMaterial.SetFloat("_OutlineWidth", 0.2f);
            //m_textMeshPro.fontSharedMaterial.EnableKeyword("UNDERLAY_ON");
            //m_textMeshPro.lineJustification = LineJustificationTypes.Center;
            //m_textMeshPro.enableWordWrapping = true;
            //m_textMeshPro.lineLength = 60;
            //m_textMeshPro.characterSpacing = 0.2f;
            //m_textMeshPro.fontColor = new Color32(255, 255, 255, 255);

            m_material01 = m_textMeshPro.font.material;
            m_material02 = Resources.Load("Fonts & Materials/ARIAL SDF BEVEL", typeof(Material)) as Material; // Make sure the IMPACT SDF exists before calling this...

        }
        else if (BenchmarkType == 1) // TextMesh
        {
            m_textMesh = gameObject.AddComponent<Text>();

            if (TextMeshFont != null)
            {
                m_textMesh.font = TextMeshFont;
                //m_textMesh.renderer.sharedMaterial = m_textMesh.font.material;
            }
            else
            {
                //m_textMesh.font = Resources.Load("Fonts/ARIAL", typeof(Font)) as Font;
                //m_textMesh.renderer.sharedMaterial = m_textMesh.font.material;
            }

            m_textMesh.fontSize = 48;
            m_textMesh.alignment = TextAnchor.MiddleCenter;

            //m_textMesh.color = new Color32(255, 255, 0, 255);
        }

        for (int i = 0; i <= 1000000; i++)
        {
            if (BenchmarkType == 0)
            {
                m_textMeshPro.text = label01 + (i % 1000);
                if (i % 1000 == 999)
                    m_textMeshPro.fontSharedMaterial = m_textMeshPro.fontSharedMaterial == m_material01 ? m_textMeshPro.fontSharedMaterial = m_material02 : m_textMeshPro.fontSharedMaterial = m_material01;

            }
            else if (BenchmarkType == 1)
                m_textMesh.text = label02 + (i % 1000).ToString();

            yield return null;
        }

        yield return null;
    }
Example #60
0
	void Start()
	{
        attachedText = GetComponent<TextMeshProUGUI>();
		timeleft = updateInterval;  
	}