HOW TO CREATE A GAME UI IN UNITY  | Create And Change Your UI In Unity | Unity Tutorial

HOW TO CREATE A GAME UI IN UNITY | Create And Change Your UI In Unity | Unity Tutorial

Dani Krossing

2 года назад

29,143 Просмотров

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


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

Karel Brouwer
Karel Brouwer - 09.03.2023 19:56

I can't drag the script into the canvas. NEED HELP PLS

Ответить
VươngVỹ Trần
VươngVỹ Trần - 05.03.2023 20:25

your video is really great, it make our project for homework easy, thank you so much.

Ответить
Dylan C
Dylan C - 09.01.2023 20:45

Probably a long shot but if anyone knows the answer lol - sometimes when my player collides with the coin (I just used a coin instead of fireflies), instead of adding +1 it adds +2. Is this because it's detecting multiple collisions for some reason? If so, how do I prevent that? Thanks!

Ответить
akif Gecir
akif Gecir - 03.01.2023 19:00

Your videos are extremely helpful! Thank you!

Ответить
Manuel Medina
Manuel Medina - 27.12.2022 02:22

very useful information to call some things from other scripts into the one u are working on, thanks!!!

Ответить
MaximumLowBlow
MaximumLowBlow - 29.11.2022 00:47

When I pick up my score object, it sometimes gets collected multiple times. Any idea why this might be? There's no duplicate object behind it, there's only 1 rigidbody/collider on my player.

Ответить
HolyDryadalis
HolyDryadalis - 15.11.2022 21:08

I have a question about the score variable, doesn't it also work if I use getters and setters instead of making the variable public?

Ответить
David S
David S - 06.11.2022 11:40

Absolute Garbage. Using Unity 2021.3.11f1 and the text can't be dragged on to the public object in the script.

Ответить
Victor Lindholm
Victor Lindholm - 10.08.2022 16:46

For me it says "Object refrence not set to an instance of an object" how do I fix this? I did what you did in the video but got this messege when trying to collect my "fireflys" :)

Ответить
Tina Cao
Tina Cao - 12.03.2022 22:18

this was so helpful!!!!!!!!!!!!!!!!

Ответить
Dani Krossing
Dani Krossing - 31.08.2021 19:38

(EDIT TO VIDEO)
Someone pointed out to me that if you update your UI using the Update() method, then you risk garbage collection happening. Which basically means the UI gets updated unnecessarily each frame, even if no changes happens to the UI. 🙂 And this might impact your games performance if you have a lot of it going on.

So here is a fix to make sure the UI only gets updated IF any changes to it has happened:

👾SCOREMANAGER CHANGES👾

public class ScoreManager : MonoBehaviour
{
private int scoreLast; // NEW FIELD THAT CHECKS IF SCORE HAS CHANGED 👈
public TMP_Text textScore;
public int score = 0; // CHANGE THE FIELD TYPE TO INT 👈

// Start is called before the first frame update
void Start()
{
textScore.text = score.ToString() + " FIREFLIES";
}

// Update is called once per frame
void Update()
{
if(scoreLast != score) // IF STATEMENT THAT CHECKS IF SCORE HAS CHANGED👈
{
textScore.text = score.ToString() + " FIREFLIES";
}
}
}

👾FIREFLYCONTROLLER CHANGES👾

public class FireflyController : MonoBehaviour
{
private ScoreManager scoreManager;

private void Start()
{
scoreManager = GameObject.Find("Canvas").GetComponent<ScoreManager>();
}

private void OnTriggerEnter2D(Collider2D collision)
{
if (collision.tag == "Player")
{
scoreManager.score += 1; // REMOVE THE "f" SINCE IT IS NO LONGER A FLOAT 👈
scoreManager.scoreLast = scoreManager.score; // UPDATES THE scoreLast FIELD 👈
Destroy(gameObject);
}
}
}

Ответить
x Casanova
x Casanova - 31.08.2021 04:24

Are u going to continue the c# series?.. i just finished them and i learned so much so quickly but I m now sad knowing that you haven't done any more videos.

Ответить
Bridge Bridge
Bridge Bridge - 30.08.2021 05:03

Why do this guy look like Elon Musk

Ответить
Skay skeleton
Skay skeleton - 29.08.2021 22:55

You are highly underrated my friend ...

Ответить
Julia Alder
Julia Alder - 29.08.2021 22:28

Thanks. I like your explanations. :)

Ответить
Khairol Hazeeq
Khairol Hazeeq - 29.08.2021 20:34

Never expected you to create a Unity tutorial! You are truly multi talented!

Ответить
Pranav
Pranav - 29.08.2021 19:22

my useless comment for engagement

Ответить
TheDisguisedCat
TheDisguisedCat - 29.08.2021 19:02

first

Ответить