Set Text Using TextMeshPro Via Script

Set Text Using TextMeshPro Via Script

TKGgames

5 лет назад

42,556 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

slowfuse
slowfuse - 29.06.2023 08:25

this video sux ass

Ответить
Regeneration
Regeneration - 28.05.2023 20:54

this isn't straight forward

Ответить
Robert Banister
Robert Banister - 20.02.2023 22:13

Not sure "this background" music is appropriate for a tutorial video

Ответить
One Step Eternity
One Step Eternity - 25.08.2022 17:43

So crazy how long it takes to just find out which package you have to declare "using TMPro;"

Ответить
신성재
신성재 - 02.06.2022 19:37

Thank you so much

Ответить
Esteban Badillo
Esteban Badillo - 11.04.2022 18:19

you are the best brother, thank you

Ответить
SAFEbros
SAFEbros - 12.03.2022 13:00

thank you brother

Ответить
AZA Seraph
AZA Seraph - 17.02.2022 00:57

Microsoft documentation helps, I started a few days ago and could fix this error once I though about it

Ответить
Holagrimola
Holagrimola - 10.01.2022 02:18

thank you so much for this! ^^

Ответить
Brady Kofahl
Brady Kofahl - 27.12.2021 02:50

I did this but it gave me an error,
"NullReferenceException: Object reference not set to an instance of an object"

Here is my code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;

public class TextUpdate : MonoBehaviour
{
private TextMeshProUGUI textMesh;
public int health;

// Start is called before the first frame update
void Start()
{
textMesh = FindObjectOfType<TextMeshProUGUI>();

}

// Update is called once per frame
void Update()
{
textMesh.SetText(health.ToString());

if (Input.GetKeyUp(KeyCode.Space))
{
health--;
}
}
}

Ответить
Allen Warner
Allen Warner - 28.11.2021 23:53

finally someone who can explain how to do this correctly.

Ответить
i said no
i said no - 21.07.2021 16:41

i have a problem with my script, can you help me out?
(basically, all i want to do, is to set all keys to saying "e")

heres the script:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;

public class textE : MonoBehaviour
{
public TextMeshProUGUI _textMeshProKeyPressed;


// Update is called once per frame
private void Update()
{
_textMeshProKeyPressed.SetText("KeyPressed: {currentInput}");

if (Input.GetKey(KeyCode.D))
{
SetCurrentKeyPressedText(currentinput, "E");
}
}
}

also in the compiler, it says: The name SetCurrentKeyPressedText does not exist in any context

Ответить
LesP56
LesP56 - 15.06.2021 18:38

Forget about your brother and your coding friend and your dog and the weather and all that stuff. Get straight to the subject in your first sentence. You present some good info here but get rid of all the other stuff.

Ответить
Андрей Скуридин
Андрей Скуридин - 27.04.2021 13:28

Most important thing is the first line of this code:
using TMPro

Ответить
Adrian Wandering
Adrian Wandering - 06.04.2021 12:58

No idea where you are from the start!

Ответить
Adast D
Adast D - 07.02.2021 01:20

THANK YOU 🙏!

Ответить
Oli
Oli - 10.01.2021 17:10

when I try to make a TextMeshPro element, it makes it a UI, but not UGUI. What do I do?

Ответить
Rintar
Rintar - 11.08.2020 14:41

Thank you for helping me with my uni project!

Ответить
neelesh
neelesh - 27.07.2020 13:48

Hmm this doesn't seem to be working right now. Have they changed the API?

Ответить