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 RazvanUzum · Sep 23, 2016 at 04:56 PM · bugvariablebug-perhapsvaluebug report

Variable value not changhing

The variable value is not changhing and it is really weird i need help.

So...

TotalBullets = TotalBullets + AmmoFromBoxes;

and

TotalBulletsText.text =""; TotalBulletsText.text += TotalBullets; // kinda weird but thats how i do it

well the variable value does not change. the text remains the same. if i do

Debug.Log(TotalBullets);

in

void Update()

then the value goes one frame the previous amount and the other frame the amount that it should be.

150 120 150 120 150 120 ...you get it

if i do it again

180 120 180 120 ...

And if i just

Debug.Log(TotalBullets);

after the variable increase it gives me the right value everytime...

TotalBullets is private

I tried many things but it seems like this is a bug. I am using unity version 5.3.5f1.

Pls help

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

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by SohailBukhari · Sep 23, 2016 at 06:03 PM

@username use TotalBulletsText.text = TotalBullets.tostring(); it will helps

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 RazvanUzum · Sep 23, 2016 at 06:39 PM 0
Share

thx it helped but the value is still the old one :p

avatar image SohailBukhari RazvanUzum · Sep 26, 2016 at 11:43 AM 0
Share

Check the code it may be possible that you are using values somewhere else in the code and your values replace

avatar image
0

Answer by terminator2016 · Sep 23, 2016 at 07:09 PM

you have to configure the base of the starter i think.

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
avatar image
0

Answer by RazvanUzum · Sep 23, 2016 at 07:08 PM

So...i replaced the variable TotalBullets with PlayerPrefs.GetInt("TotalBullets") so now it works but i still want to know why it did not work with the variable ... its very weird i checked it multiple times and i think its a bug ... But yea thx

Comment
Add comment · Show 1 · 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 · Sep 26, 2016 at 01:45 PM 0
Share

I think you'd need to show us more code (the actual code) and explain things more fully (for example, you cannot have simply replaced that variable with a call to PlayerPrefs.GetInt(), since you cannot assign to the latter, plus you are not using PlayerPrefs.SetInt() anywhere).

But one possibility is that you've got multiple instances of the script, and the variable is only being changed in one of them. If you've moved to system where those different instances are both getting a value from a common place, then one would expect the symptoms to go away.

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

6 People are following this question.

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

Related Questions

TextMeshPro Object not updating in real time 0 Answers

Unity bug? Coroutine couldn't be started inactive game object 0 Answers

Unity Line Renderer drawing extra line to another point.. 0 Answers

Animation load bug 0 Answers

Script only works if i enable/disable it in inspector 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