Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 ShirazAkber · Oct 15, 2019 at 08:30 AM · uitextscoreint

Score text wont appear

Hello i was following the roll-a-ball tutorial and after i made the public text on my ball and dragged the text onto it,there is a problem. The text that i want to appear is shown but the iteration of score is not being shown.

 public class Acc : MonoBehaviour
 {
     public Text capsuletext;
     private int capsule;
     public Text timertext;
     private Rigidbody rb3d;
     public GameObject changer;
     // Start is called before the first frame update
     void Start()
     {            
         capsule = 5;
         rb3d = GetComponent<Rigidbody>();
         setcount();        
     }
     void Update()
     {
         setcount();
         transform.Translate(Input.acceleration.x, 0,0);
     }
     public void Jump()
     {
         rb3d.AddForce(0, 300, 0);
     }
     public void Rjump()
     {
         rb3d.AddForce(0, -300, 0);
     }
     void OnTriggerEnter(Collider collision)
     {
         if (collision.gameObject.CompareTag("Bound"))
         {
             SceneManager.LoadScene("Gameover");
         }
         else if (collision.gameObject.CompareTag("Capsule"))
         {
             collision.gameObject.SetActive(false);
             capsule = capsule - 1;            //the score of 5 that is suppose to reduce to 0 is not being shown
             setcount();
         }            
     }
     void setcount()
     {
         capsuletext.text = "Remaining : " + capsule.ToString();      //THE "Remaining" IS BEING SHOWN
         if (capsule <= 0)
         {
             changer.SetActive(true);
         }
     }
 }

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 Bonfire-Boy · Oct 15, 2019 at 09:29 AM 1
Share

capsule.ToString() is going to add something to that string whatever the value. So, so long as setcount() is being called (it's not clear that you know this for sure), the string being passed to the text element does have an integer at the end.

If the integer's not being seen then most likely I$$anonymous$$O is that it's just be being truncated due to the size of the text element. You could check this very quickly by changing it to

capsuletext.text = capsule.ToString();

If that's the issue you've got several options, for example: increase the size of the text element, reduce the font size, make it use "best fit".

avatar image HappiiGamer · Oct 15, 2019 at 12:51 PM 1
Share

Do I understand correctly, you see a ball with the word "Remaining:" over it but no count? When you pause the game in editor and you select the text in the inspector, does it also just say "Remaining:"?

avatar image ShirazAkber HappiiGamer · Oct 16, 2019 at 07:41 AM 0
Share

Yes sir it does it only shows "remaining" and not the numbers i want it to be like this Remaining : 5(this number keeps decreasing)

1 Reply

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

Answer by ShirazAkber · Oct 16, 2019 at 07:46 AM

Guys i got it working the problem was that i was using a font called "Rosbed" which didn't show the numbers when i changed it back to "Liberationsans" it worked perfectly. any idea why the other font doesn't show the score? @HappiiGamer @Bonfire-Boy Thank you so much.

Comment
Add comment · Show 2 · 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 Bonfire-Boy · Oct 16, 2019 at 09:49 AM 0
Share

If you download free fonts, sometimes you get a demo version that doesn't have all the characters. If you go back to where you got it from you may find that there's an option to buy the full font.

avatar image HappiiGamer · Oct 16, 2019 at 12:51 PM 0
Share

Ah yes, the font. It's always good to open the Font $$anonymous$$ap and see what Characters it has. I have had this problem with pixel fonts which often don't have the special characters. There are simple programs out there that allow you to add some of your own characters into the existing Font $$anonymous$$ap if you want to keep it in your project. Another side note, it's good to plan the fonts in advance in a project, as you might want to translate your game at some point into Japanese, for example, and you might realize the font you have is completely off.. Talking from experience.

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

199 People are following this question.

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

Related Questions

Old school score text 3 Answers

How can i link my code together so the score value affects the timer value 1 Answer

Add multiple ints to a string line. 2 Answers

Displaying variable on UI text every frame (JS) 1 Answer

Need help with adding score from 2 different script C# 4 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