Search Unity

First tutorial Roll-a-Ball: Display text & Adjust coords of rectangle is very wrong!!!

Discussion in 'Community Learning & Teaching' started by KingfisherWyvernStudio, Jan 25, 2015.

  1. KingfisherWyvernStudio

    KingfisherWyvernStudio

    Joined:
    Oct 5, 2011
    Posts:
    324
    Hey all,

    Okay, it seems I posted my original thread int he wrong forum, so here goes:
    Hi,

    I've finally just started with learning Unity and I thought the best place to start was one of Unity's own tutorials, so I chose Roll-a-ball.

    I ran into a problem with displaying the score (chapter 7 of the tutorial: Displaying Text).

    Just to be clear: I have the free version of Unity (version 4.6.1f1, downloaded yesterday, installed today). I have no idea if this makes any difference, but I thought I'd better mention it.

    Here's the thing:
    The tutorial tells you in chapter 7 to add a new game object and call it Display text (so far so good). Next, you need to create a new object from the hierarchy called GUI text.
    Now, there's no GUI in the hierarchy nor in the GameObject menu, so I chose UI -> Text.
    Instead of getting a simple GameObject called Text I got Canvas -> Text.
    At first I thought that wouldn't be a problem, simply move the entire "Canvas -> text" to Display Text as a child, instead of only the object Text. Sure, that wasn't a problem. The problem, however, is that you can't adjust the Rect Transform within Canvas, causing it to automatically have:
    X position of 355,
    Y position of 203.5 and
    Z position of 0,
    while according to the tutorial video, the rectangle with the text "new text" should hover above the plane, next to or under the sphere. In reality (or at least my reality) it's no way near any of the other game objects.
    All the other game objects have a center point at 0, 0, 0, and adjusted from there, like stated in the tutorial video.

    Using reset form the Cog of the Rect Transform in the Canvas doesn't change a thing (as in: it doesn't center the rectangle to the 0,0,0 position nor anything else).
    Also, besides adding the Canvas -> text somehow I also get an EventSystem game object in my hierarchy at the same time. It wasn't there before I added the UI -> Text and after I had added it and the Canvas -> Text showed up, the EventSystem. Where did that come from? What does it do? Do I need to keep it?

    To move the rectangle (and accompanying text) to the proper position, I need to go into the game object "Text" (renamed to Count Text) and use the Rect Transform there and add:
    X position: -355
    Y position: -202.5
    Z position: 0
    Instead of the proposed: 0,1,0 from the tutorial.
    Using the reset function from the Cog in this Rect Transform doesn't do squad to it's weird original positioning.

    This seems rather..... very wrong. I expected the Rect Transform from the canvas to be positioned close by the center point of the game (0, 0, 0) and at least to be adjustable, like this page suggests:
    http://docs.unity3d.com/Manual/class-RectTransform.html

    Why is this happening? Is this because of a difference between the free version and the Pro version? Am I doing something wrong? Is it somehow a bug?

    For a beginner, this part of the first beginner tutorial is rather... complicated, if I may say so.

    I have tried to follow Graham Dunnet's steps as posted here:
    GUI Text - Just can't fathom but..... I get exactly the same problem as described above. I don't have GUI, only UI and then the Text, Message, etc options.

    I've also tried to follow the tutorials about the UI, but the first tutorial says you can NOT edit the Rect Transform while the second says you CAN edit the Rect transform when you select the Rectangle mode instead of the Pan, rotate, scale, etc mode. But when I try that, I still can't edit the Rectangle from the canvas. Still only from the text which is a child from the canvas and then I have to make the ridiculous adjustments I posted above.

    Or maybe I'm just understanding it wrong because I've been trying to make sense of all the information I've been reading to see if I can find what's wrong.

    How do I solve this problem?

    Thanks for the help!
     
    Last edited: Jan 25, 2015
  2. KingfisherWyvernStudio

    KingfisherWyvernStudio

    Joined:
    Oct 5, 2011
    Posts:
    324
    Update: Apparently I needed to reboot my PC and Unity, since essentially that's what I did (went to bed so shut down the PC :D )

    I just started Unity up and opened the project. I decided to try once more to add the text and lo and behold, it works! I'm not sure why it wouldn't reset the position to 0, 0, 0 yesterday, but at least it works now as it supposed to do!
     
  3. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    First off, this project is over a year old, and there have been some subtle changes to Unity since it was created. The main one is the addition of the new UI tools in 4.6. TBH, this addition probably deserves an annotation as this has a big impact on the project. I will also be creating an upgrade guide for both Roll-a-ball and Space Shooter, which I will link.

    No, this issue is not due to "Free". At best, it's due to the update to Unity in 4.6

    The "GUIText" component still exists, yes. But due to the addition of the new UI tools, you need to add the component directly. There is no shortcut to create these directly anymore. You can reach the same stage by:
    • Creating a new GameObject
    • Add Component: Rendering/GUIText


    These two systems are distinctly different. One cannot apply the steps of a GUIText item to a UIText item. Moreover, when using the new UI tools it is possible to have certain items on the RectTransform being driven by the parent. For more information on the new UI tools, please see the modules in the "Learn" section of the Unity site:
    http://unity3d.com/learn/tutorials/modules/beginner/ui

    The event system and canvas are created automatically when creating any UI Element from the "Create" menu, as all UI Elements need to be the child of a canvas, and for a UI Element to accept input (buttons, etc.) they need to have an Event System. For simple text, the event system is not necessary.

    That being said, as opposed to this very simple lesson, in most cases a UI will need interactivity, so the Event System would be necessary.

    Root Canvases set their own RectTransform according to your screen, and the user doesn't, and shouldn't, have control over the root canvas.

    This is not a problem / difference between Pro and Free.

    You are (arguably) doing nothing wrong.

    This is not a bug, this is probably a misunderstanding about how to use the new UI tools that you've stumbled across. Best to use the link above and see how to use the new UI tools, or create a GUIText item from the Component Menu.

    I'll have a look at that thread and post any information I need to there.

    See above about access to the RectTransform on the Root Canvas. My assumption is that, having just started with Unity, you may have missed the details re: the RectTransform on a UI Element and an RectTransform on the Root Canvas.

     
  4. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    So, it looks like you've solved you problem?

    Add to this post if you need any more help.
     
  5. KingfisherWyvernStudio

    KingfisherWyvernStudio

    Joined:
    Oct 5, 2011
    Posts:
    324
    Hey @Adam Buckner ! Thanks for all the explanations! I know see the differences. Thanks for explaining them :) @SimonDarksideJ gave links to updated videos for the particular tutorial I'm working with. I'll watch those and adjust my project where needed and see if I have any questions left after that. At the moment I don't have any more questions/problems left. If I do, I'll post them here :)

    Thanks again, both of you, for your excellent help! It's great to have people here to help out newbies with the program!
     
  6. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    There is always this too.

     
  7. KingfisherWyvernStudio

    KingfisherWyvernStudio

    Joined:
    Oct 5, 2011
    Posts:
    324
    Yeah, that's what I was referring to in my earlier post :)
     
  8. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    Cool. Glad it's helped out.

    (And never above a little shameless self promotion)
     
  9. Napivo

    Napivo

    Joined:
    Feb 9, 2015
    Posts:
    39
    I really hope they change the end of the tutorial to this (even tough this is for PC and the tutorial for mac) I use PC.

    No complaints tough. neither for unity or you this helped me a lot

    Thanks a Lot :)

    (This was my first test)
     
  10. NoGame

    NoGame

    Joined:
    Feb 10, 2015
    Posts:
    1
    What unity version was used in the roll-a-ball videos and can older versions be downloaded?
     
  11. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    Older versions can be downloaded. I believe Roll-A-Ball was made in 4.0.

    I would strongly recommend sticking with the latest version.