- Home /
Project: Space Shooter - GUIText vs UI/Text in Unit3D 4.6
Greetings. I am following the lessons of "Project: Space Shooter" but in chapter 1 in Lesson 15 I am not able to continue. The command "GUIText" is not available in version 4.6. Only the command "UI/Text" and does not accept the parameters correctly. How can I solve this? Thank you for your attention.
Thanks for your help. The first solution to use the "Empty Game Object" and then the GUIText was perfect. After completing the tutorial will learn better how to adapt to "UI.Text". Thank you all.
Answer by Rtyper · Feb 19, 2015 at 01:22 AM
The old style GUIText and GUITexture components are still available (for legacy purposes), though you can't create them from the GameObject menu anymore.
You can create an empty GameObject from there, and add a GUIText component from the Component/Rendering menu to continue with the tutorial. You may want to look at some of the tutorials on the new 4.6 UI system and try to adapt the Space Shooter tutorial to that though - it's definitely much more flexible than GUIText, and is still being updated.
Answer by DiegoSLTS · Feb 19, 2015 at 01:42 AM
There's nothing to "solve", the tutorial is outdated and what it tells you to do it's not available. You can still use the legacy GUI through code, but that's more complicated than what the tutorial is trying to teach you.
The new Text object has a lot of new options, if you want to get the same result as the tutorial do this:
Set the Text anchor to top-left. On the inspector you'll see it has a Rect Transform instead of the normal Transform, the anchor can be set clicking on the icon at the top left of the Rect Transform component. Click on that icon and you'll see a table of different anchors.
Set the pivot of the Rect Transform to x = 0, y = 1. The pivot is the point that's used as referente for positioning the object. x = 0 means the left of the rectangle, y = 1 means the top.
If you try different anchors you'll see the values at the right change, for some options you'll see "top, bottom, left, right", for others "pos x, pos y, width, height" and for others any combination of those (pos z is always there). With the anchor set as step 1 you should see "pos x, pos y, width, height" options. When you see "pos x" and "pos y" they work like the pixel offset in the legacy GUI.
Later in the script you need a reference to the Text object. Instead of using GUIText you need Text, but to be able to type "Text" as a type you first need to add a using for the UI namespace. Add this line right after "using UnityEngine;":
using UnityEngine.UI;
You can follow the tutorial from here.
Your answer
![](https://koobas.hobune.stream/wayback/20220613183717im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
"AI"/Behaviour for a Waypoint system 1 Answer
3D spaceshooter : targeting system 3 Answers
Strategies for Physics-based Movement for 2D Space RTS Controls? 1 Answer
[2D] How to instantiate laser when player rotates? 1 Answer
Shooting Lasers 3 Answers