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 /
  • Help Room /
avatar image
-1
Question by cyper43 · Jun 29, 2016 at 07:30 AM · uitext

Problem displaying a variable with UI Text

Hi, i created a UI.Text object to display the number of gold colected in a clicker game, but it only displays the tet directly inputed into the text box. this is the script that i used to try to display it.

 using UnityEngine;
 using System.Collections;
 using UnityEngine.UI;
 
 public class Click : MonoBehaviour {
 
     public int Gold = 0;
     public int goldPerClick = 1;
     public Text goldDisplay;
 
     void start()
     {
         countGold();
     }
 
     void update()
     {
         countGold();
     }
 
     public void Button(){
         Gold = Gold + goldPerClick;
 
     }
 
     void countGold()
     {
         goldDisplay.GetComponent<Text>().text = "Gold: " + Gold.ToString();
 
     }
 
 }
 

i tried using: goldDisplay.text = "Gold: " + Gold.ToString(); goldDisplay.GetComponent().text = "Gold: " + Gold; goldDisplay.GetComponent().text = "Gold: " + Gold;

the variable changes but the text isnt displayed. can anyone help me?

Comment
Add comment
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

1 Reply

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

Answer by saschandroid · Jun 29, 2016 at 07:55 AM

Programming is case sensitive. You have to use Update() and Start() otherwise these functions aren't called by unity.

Comment
Add comment · Show 4 · 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 cyper43 · Jun 29, 2016 at 08:04 AM 0
Share

Oh that i didnt know, since i just programmed in jprocessing and c# is fairly similar to java i thought it wasnt case sensitive. Thank you

avatar image Flaring-Afro cyper43 · Jun 29, 2016 at 12:31 PM 0
Share

What? Java is case sensitive too.

avatar image Owen-Reynolds Flaring-Afro · Jun 29, 2016 at 02:03 PM 0
Share

People with typical aggressive IDEs can easily not know their language is case-sensitive. They may have heard it mentioned once, but you type "FOR" and the IDE automatically lower-cases and turns it cyan. You know the cyan is to make it pretty, so you can easily assume the lower-casing is also cosmetic.

That's probably why so many mess up Update and OnTriggerEnter.

And, just to be thorough, program$$anonymous$$g itself isn't case-sensitive. There are non-case-sensitive languages, just not so common any more.

Show more comments

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

UI TEXT not showing up in game mode 1 Answer

GameObject destroyed when changing scene 1 Answer

uGUI Text draw calls 1 Answer

I can't change Text color 3 Answers

Show a text in the position of a GameObject 0 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