- Home /
The question is answered, right answer was accepted
Is the GUI text still viable?
I want to create a text to display the score for my game and the space shooter tutorial uses a GUI text to do so, but it has the message "This component is part of the legacy UI system and will be removed in a future release." So should I use this or is there a better alternate solution? And what is the difference between normal text and GUI text?
Answer by Pinkuboxu · Jan 19, 2018 at 10:07 PM
I'd think of it like, as long as your score is in a variable then you just have to change it later when you have to. I'd worry about fixing it after you finish the tutorial. It will probably still work for some time. So learn now, don't get too paranoid about deprecation until you are making a commercial product. ;)
But when you get there you need to be "using UnityEngine.U"I and a Text type which can hold the new GUIs Text Component. Usually you start by just creating a Canvas with a Text component, either in the editor or procedurally. GetComponent to reference it (or make it public and set it in the inspector) and use its .text property to change what it displays.
Oh, and to answer the last part, I think it's the difference between the new GUI system and the old way. I don't have much experience with the old way though.
Thank you for the reply! Just a quick question, what does "using UnityEngine.U"I mean and how would I add/use that?
The C# "using" keyword in general is so you can use namespaces from other code in your project, without having to constantly type the whole namespace in. It's what the "using UnityEngine" is for. There are a lot of these namespaces both in Unity and for the standard C# language. The "UnityEngine.UI" (I didn't catch the wonky typo, sorry) it's the namespace for all the GUI stuff in the newer system. So you can define and reference objects without having to type "UnityEngine.UI" before every method or other class use. I hope that's what you where needing. Forgive me if I'm assu$$anonymous$$g, but have you done any plain .NET C# coding tutorials? This will help you immensely in understanding the C# language and it's implementation in Unity.
I've started using Unity a couple months ago and I'm trying to learn some C# coding while creating a game, so I'm still unfamiliar with a lot of the terms used in C#. Thank you for the clarification though!
Follow this Question
Related Questions
GUI HELP!!!!! 1 Answer
Level Button And Quit Button Android 2 Answers
help with Gui texts 2 Answers
In Game player message - GUIText or something else? 1 Answer
I need help with my GUI text for my Real Time Strategy Game 0 Answers