Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

GUIText not working.

Discussion in 'Editor & General Support' started by Raz, Apr 19, 2012.

  1. Raz

    Raz

    Joined:
    Mar 23, 2012
    Posts:
    6
    GUIText is not working for me, at all.
    I have a scene with 1 camera, it doesn't have a parent.
    I have the GUI Layer YES.
    When I add GUIText and enter text it just doesn't show up.

    I tried:
    Deleting EVERYTHING on the scene, except the camera. Still doesn't work.
    Using a new camera.

    IT DOES work if I start a new project, and add GUIText to the camera.

    So, is there a setting I could have changed in this project?

    I appreciate any help. I am so confused why this just isn't working.
     
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    GUIText and GUITexture use viewport coordinates. If the x or y coordinates are outside the 0..1 range they won't be visible.

    --Eric
     
    ocimum and Ramael like this.
  3. Raz

    Raz

    Joined:
    Mar 23, 2012
    Posts:
    6
    Eric,

    I don't see anything different anywhere on this project compared to a new project. It has to be a setting somewhere that is making the GUIText not render.

     
  4. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    You really shouldn't have the GUIText component on a camera. It should be a separate object.

    --Eric
     
  5. Raz

    Raz

    Joined:
    Mar 23, 2012
    Posts:
    6
    Even though it works on the camera on a new project I still tried your advice, no luck. I took it off the camera, and placed it on another object to no avail. It just wont work in this project for some reason. I can delete EVERYTHING from the project and start new and it still wont work. Something got changed in the project. Some setting, which I would LOVE to know what so I can not have to scratch an entire scene that was 99% complete. If some setting didn't get changed, it has to be a bug.
     
  6. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    You can always export the scene as a package and import it into another project.

    --Eric
     
  7. Raz

    Raz

    Joined:
    Mar 23, 2012
    Posts:
    6
    New update.

    1) Changing the GUIText Y to 650 put's it roughly in the right spot... why though? (Screenshot included)
    2) EVEN if I export the scene and import it into a new project the problem still happens. There are 0 problems with
    using a new scene / project. Just some problem with this scene.

     
  8. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    As I said, GUIText/GUITextures use viewport space. That means you can't make them children of the camera, which uses world space. There's no reason to, either. Just make them separate objects.

    --Eric
     
  9. imphenzia

    imphenzia

    Joined:
    Jun 28, 2011
    Posts:
    413
    I filed a bug report for this behavior now. My GUIText isn't showing and I can only relate it to me accidentally deleting Main Camera from my scene and then creating a new camera object. Regardless of what I do I can't get the GUIText to appear (adding it to another object or the camera itself).

    You can recreate this problem:
    1. Create a new scene
    2. Delete Main Camera
    3. Create a new Camera (GameObject > Create Other > Camera)
    4. Add GUIText to the camera and enter a test text... nothing appears?
     
  10. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    That's a waste of everyone's time, since there isn't a bug. Please do what I said and make the GUIText a separate object. It should not be a child of the camera, it should not be a component on the camera. It must be a totally separate independent object because it uses viewport space, not world space. It works 100% correctly: GameObject > Create Other > GUIText. Do not move it away from the 0..1 range in x/y or it won't be visible.

    --Eric
     
    ocimum likes this.
  11. imphenzia

    imphenzia

    Joined:
    Jun 28, 2011
    Posts:
    413
    I miss understood your previous post because I created a separate gameobject that I then added GUIText to (I incorrectly didn't make it an entirely own object.)

    UPDATE: Doh, and of course you can have it as a separage gameobject only it wasn't in view because of the way the Y-coordinate works... 0,0,0 puts it out of view so 0,1,0 puts it in the right place - that's why it didn't work for me.

    Sorry for taking up unnecessary time.
     
    Last edited: Apr 25, 2012
  12. kanga

    kanga

    Joined:
    Mar 22, 2010
    Posts:
    225
    I have done all the above and I still cant see a freakin thing in Unity 4.

    AAAARRRGGGHHHH
    :)
     
  13. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Don't look at the scene view, look at the game view.

    --Eric
     
  14. gabeturow

    gabeturow

    Joined:
    Jan 21, 2013
    Posts:
    3
    is the GUI layer checked on the checkbox on your camera?
    I just solved this same issue for myself by just checking that box.
     
  15. Dryson

    Dryson

    Joined:
    Dec 28, 2012
    Posts:
    29
    Look under Pixel Offest you will see an x and y coordinate value. Change each of the values to 1 and the GUI Text will be displayed.
     
  16. karchi90

    karchi90

    Joined:
    Mar 11, 2013
    Posts:
    1
    Hello,
    try this.

    make sure your GUI Text position is at X 0.5 Y 0.5 Z 0
    (this is the default value in world space)

    if you have moved this object it shall not be displayed in the correct location on screen.
    make sure the GUI text is an object on its own and not parented to the camera.
    (it does not matter where your camera is positioned in world space as the two are not linked directly)

    if you have moved the GUI text, open up the transforms tab and make sure your position is set to the default values above.
    (Transforms tab on GUI Text is closed by default - click the arrow to open it up)

    Enjoy!
     
  17. alberto-lara

    alberto-lara

    Joined:
    Jun 13, 2013
    Posts:
    24
    But the GUI Text should have be in scene view too, Eric.
     
  18. MikeBastien

    MikeBastien

    Joined:
    Apr 24, 2009
    Posts:
    139
    FWIW: This is the default if you use the 'Create' menu in the 'Hierarchy'.

    If you just create a new Game Object, and the GUIText as a component, the position can be anywhere.

    Ideally the script itself would handle this possibility through OnValidate or something.

    I haven't used GUIText in a while, and had to search out why it wasn't showing up either...
     
  19. pavlito

    pavlito

    Joined:
    Nov 27, 2007
    Posts:
    136
    I have a similar issue.

    When I create a GUIText object, the default font is Arial and everything works ok.
    As soon as I change the font, the text disappears.
    To make things more silly, while in play mode (paused) i edit the font itself (change char size) the text appears but as soon as i hit "unpause" the text disappears. Its VERY strange, because it works in my other project.

    The GUIText object is a part of my GuiManager object which shows messages and stuff. This GuiManager was exported as a package from another project where everything works.

    I have realized it's not working when I was doing a tutorial level where the messages usually show up. Still don't have a solution. I will just use Arial :p
     
  20. kieranahayes

    kieranahayes

    Joined:
    Mar 26, 2013
    Posts:
    3
    I've started using GUI Text and I am having similar problems, but it seems as though the answer may be as simple as "use 3D Text instead". So am I correct in saying that the only way to position a GUI Text is to use the pixel offset? This means that the location of the text will appear in a different location on the screen based on the resolution of the device, unless you set up an algorithm to determine what you want your pixel offset to be based on the resolution of the current device.

    3D Text seems to avoid these issues by using the world space, or 'unity units', to set the location of the text. I guess it could be determined on a case-by-case basis but with Unity's cameras I'd be surprised to find a reason to use the GUI Text.
     
  21. RavenBlackX

    RavenBlackX

    Joined:
    Nov 17, 2013
    Posts:
    3
    kieranahayes - you're not limited to pixel offset to move it, you can also move it by adjusting the transform position. With pixel offset unchanged, y=0 is the bottom of the screen, y=1 is the top, x=0 is the left, x=1 is the right, and z determines which GUI elements go in front of others. So with that kind of positioning it will adjust by your resolution (and if you're doing that then you probably should not use pixel adjustments of more than a few pixels). Not sure if the font *size* automatically adjusts by screen size though.
     
  22. Radiox

    Radiox

    Joined:
    Dec 23, 2013
    Posts:
    1
    Switching to game view did it for me :) Thanks, didn't check there as a 3d text does show up in the scene view.
     
  23. aneto

    aneto

    Joined:
    Feb 18, 2014
    Posts:
    1
    It worked for me.
     
  24. A-Tunga

    A-Tunga

    Joined:
    Jul 13, 2014
    Posts:
    13
    Thanks.Worked for me.To Transform X 0.5 Y 0.5 Z 0 than i changed it what ever i want :)
     
  25. albertofdb

    albertofdb

    Joined:
    Aug 6, 2014
    Posts:
    2
    For me too. Thanks
     
  26. Bropoc

    Bropoc

    Joined:
    Sep 30, 2014
    Posts:
    8
    I'm also having the issue of invisible GUItext. The transform is 0.5, 0.5, 0, and it's not even a child object to anything.

    Edit: No, wait, I just realized that the camera OBJECT has more settings than the camera COMPONENT.

    Welp.
     
  27. uareurapid

    uareurapid

    Joined:
    May 14, 2014
    Posts:
    5
    From my experience with this i can say i also had issues with this... For me the problem was the GUI Text color, if i choose black (0,0,0) i don´t see nothing on screen, any other color and the GUI text shows properly... IMO there is some editor bug...
     
  28. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    I don't think so; I suspect you had the alpha set to 0 as well.

    --Eric
     
  29. apollolm

    apollolm

    Joined:
    Dec 8, 2014
    Posts:
    1
    Your comment about the difference between an OBJECT and a COMPONENT helped me! Thanks! I'm using the Oculus Rift/Unity OVRPlayerController, which comes with camera components, NOT camera objects. To see why GUI Text was not showing up for me, I took a look at the regular Camera object and noticed it had a GUILayer component. So, I added this GUILayer component to both of the OVRCameraRig's camera-like components. I also set my GUI Text object's layer to be UI.

    This made the text show up for me in Unity with Oculus viewer.
     
  30. jiangC

    jiangC

    Joined:
    Sep 10, 2014
    Posts:
    2
    Just change Line Spacing
     
  31. Dan Snow

    Dan Snow

    Joined:
    Mar 5, 2015
    Posts:
    2
    Worked For Me, been bugging me for hours.
     
    neeraz2064 likes this.
  32. neeraz2064

    neeraz2064

    Joined:
    Mar 22, 2015
    Posts:
    1
    Thank you very much, it does not really show text in the scene mode but it shows in the game mode. It seems the coordinate starts from lower left corner as (0,0,0) to the upper right corner as (1,1,0) if the range is out than the text is displayed out of the scene and not visible.
     
  33. Tsilliev

    Tsilliev

    Joined:
    Jan 21, 2014
    Posts:
    34
    Why did they make this so stupid? I make empty object, I put guitext component, I write something, I should see letters! Tried putting it under the camera, which is basically in front of my face with the famous 0.5x,0.5y,0z transform and still nothing. I think this feature is broken.

    What i did was just go to:
    GameObject - 3D Object - 3D Text and finally I can see some text displayed in front of me.


    Edit: Okay i found out how to put simple text on the screen not in the scene in the world, but on the "Game" screen. You go to GameObjects - UI - Text and make the color white or its difficult to see it, here is a picture:
     
  34. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    It's not broken or stupid (don't put it under the camera, put it on a different object), but yes, you should use UI components rather than GUIText.

    --Eric
     
  35. Ramael

    Ramael

    Joined:
    May 27, 2015
    Posts:
    2
    Thank you sir! This worked for me! My GUI Text was at (transform) position X=0 and Y=0 (and Z=0), and then I changed it to X=0.5 and Y=0.5 and it appeared! :D
     
  36. noodlesdev

    noodlesdev

    Joined:
    Jun 16, 2015
    Posts:
    5
    Well, that helped :D, thanks!
    But why can't you see it in the scene view ?

    UPDATE:
    Never mind already know why :)
     
    Last edited: Jul 14, 2015
  37. walkthisway12

    walkthisway12

    Joined:
    Nov 17, 2015
    Posts:
    2
    I'm having a similar issue. In game mode I can see my GUI Text ( x = .05 ; y = .95 - so it appears in top left corner) but as soon as I press play it disappears. I have a script that activates the GameObject (with GUI Text as a component). You can see the GameObject come live at the specified time in the hierarchy so I don't think the script is the issue.
     
  38. Deleted User

    Deleted User

    Guest

    @Eric5h5 Hey, Eric,

    All GUI Text in Unity5.6.1 looks like the image I have attached.
    Help me out please.:):)
     

    Attached Files:

  39. dragonkioku119

    dragonkioku119

    Joined:
    Jul 16, 2017
    Posts:
    13
    If you are in Unity 2017 right click and use UI->Text. It'll make a canvas with a text object attatched. I'ts not a GUI Text. Anything I tried with GUI text would not work.