Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by alexan1 · Dec 13, 2014 at 01:38 AM · roll a ballnew uigui-text

gui text is absent in Unity 4.6

I follow this Roll a ball tutorial. According to it, I need to add Gui Text to show score. But it's absent in Unity 4.6. Should I add Text from UI instead?

If I try this I get error:

MissingComponentException: There is no 'RectTransform' attached to the "Display Text" game object, but a script is trying to access it.

And I don't see any labels in UI. What object should I add instead Gui Text?

Comment
Add comment · Show 3
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image MrSoad · Dec 13, 2014 at 12:48 AM 0
Share

Yes try the UI as you thought, yet to try myself but from what I have read this is the way to go :)

avatar image alexan1 · Dec 13, 2014 at 01:02 AM 0
Share

not sure how to use it. Can I just add Text? Or I need add Panel first?

avatar image MrSoad · Dec 13, 2014 at 01:38 AM 0
Share

Really don't know yet, not upgraded, sorry :S

Will publish for you, you should get someone who knows about it and is able to give you a proper answer :)

4 Replies

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by Eric5h5 · Dec 13, 2014 at 04:32 AM

GUIText is not absent in 4.6. You can add the GUIText component as usual; it's in the same component menu where it's always been. It's only the GameObject+GUIText creation shortcut that is gone.

Comment
Add comment · Show 6 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Kiwasi · Dec 13, 2014 at 08:08 AM 0
Share

Totally true. But unless you really need the legacy functionality, I would strongly suggest taking the time to learn the new tools. Especially if you are just starting out and have no previous knowledge of the old way.

avatar image alexan1 · Dec 13, 2014 at 10:03 PM 0
Share

don't see GUIText in menu. But anyway going to use Text ins$$anonymous$$d.

avatar image Eric5h5 · Dec 13, 2014 at 10:07 PM 0
Share

It's in the component menu, as I said. Where it's always been. The component menu. Not the gameobject menu. Component.

avatar image alexan1 · Dec 13, 2014 at 11:05 PM 1
Share

okay, I did as in the next answer: Create a new empty game object, then click on "add component" in the Inspector window and then type "GUIText" in the search box.

Now I see it.

avatar image alexan1 · Dec 17, 2014 at 03:09 AM 0
Share

I want accept other answer.

Show more comments
avatar image
6

Answer by Kiwasi · Dec 13, 2014 at 01:55 AM

Got irritated enough to redo the video, enjoy.

http://youtu.be/IViD5G2ucNs

Original Answer

I have a bunch of tutorials in my profile that should show you the basics of working with UI Text. There is also a tutorial in the learn section on UI Text.

Couple of things to note

  • Add using UnityEngine.UI at the top of your script

  • Create a Text using the Create -> UI menu. This will automatically add the other GameObjects the UI system needs. (Canvas and EventSystem).

  • Change the public variable from GUIText to Text

  • Modify it with the .text property

Comment
Add comment · Show 12 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image MrSoad · Dec 13, 2014 at 02:27 AM 0
Share

Thanks(+1) :)

Is pond wars out yet?

avatar image alexan1 · Dec 13, 2014 at 03:30 AM 0
Share

okay, added public Text Score in class PlayerController, then Score.text = "Score" + count.ToString() to Start(); get NullReferenceException: Object reference not set to an instance of an object Did I miss something?

avatar image Kiwasi · Dec 13, 2014 at 03:35 AM 0
Share

Did you assign Score via the inspector? This is a common cause of a null reference exception.

Also note that convention is to use capitalise ClassNames and use camel case for variableNames. It will make it easier for you to read others code and have others read your code if you follow this convention.

avatar image alexan1 · Dec 13, 2014 at 03:38 AM 0
Share

assign Score to which object?

avatar image Kiwasi · Dec 13, 2014 at 03:44 AM 0
Share

Score should be assigned to the UI Text component that you created. Just drag the UI GameObject from the heirachy across to the Score space in the inspector.

Show more comments
avatar image
0

Answer by screenname_taken · Dec 13, 2014 at 11:02 PM

Create a new empty game object, then click on "add component" in the Inspector window and then type "GUIText" in the search box. The older gui is hardly legacy, the new one is built on top of it. If you want something to just show a counter on the top of the screen, i'd go with that instead of making a canvas, adding stuff to it all just to show that.

Comment
Add comment · Show 6 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Eric5h5 · Dec 13, 2014 at 11:05 PM 1
Share

The old GUI is very much legacy, and the new GUI has nothing whatsoever to do with it. You can check the UI code if you want (the source is available), to see for yourself.

avatar image alexan1 · Dec 13, 2014 at 11:08 PM 0
Share

okay, now I see it

avatar image Kiwasi · Dec 14, 2014 at 02:12 AM 0
Share

Nor sure weather to vote you up for providing explicit, easy to follow instructions, or down for saying there is a relationship between GUIText and the UI.

avatar image screenname_taken · Dec 14, 2014 at 06:47 PM 0
Share

Did they say in one of their tutorials/videos that the system won't be abandoned as it's useful to have a "direct" route? Honestly i heard them saying "it's built on it". Unless they were meaning more something like expanding.

avatar image Eric5h5 · Dec 14, 2014 at 06:58 PM 0
Share

No, they never said "it's built on it" or anything close to it; I'm afraid you misunderstood somehow. I've never seen them say GUIText won't be abandoned, and I wouldn't be surprised if it was removed at some point. I can't see how it's really any more "direct" than UI Text.

Show more comments
avatar image
0

Answer by relenting1 · Jan 11, 2015 at 09:21 AM

http://youtu.be/IViD5G2ucNs

For all who need the answer here it is!!!!

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How Can I Make it Where Text Shows and the Game Ends on Collision? 2 Answers

GUI Text element disappears when I am trying to change its position 1 Answer

Restrict Scaling of Object due to camera position and angle. 1 Answer

Cube won't rotate in roll-a-ball tutorial 2 Answers

Roll a Ball Tutorial does not work. Help? 3 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges