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.

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:

  1. 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.
  2. 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.
  3. 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.

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.