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 /
This question was closed Jul 15, 2017 at 07:51 AM by badri21 for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by badri21 · Jul 15, 2017 at 07:29 AM · if statementif-else

If statement not working properly

here is the code

if (level_completed == 1) { string temp = "Level_" + (level_current + 1); Debug.Log(temp); bool temp1 = PlayerPrefs.HasKey("temp"); Debug.Log(PlayerPrefs.GetInt("temp")); Debug.Log(temp1); if (temp1==false) { PlayerPrefs.SetInt(temp,0); } }

and my problem is temp1 is returning false even though i am having a key as temp string in my playerprefs.

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 FlaSh-G · Jul 15, 2017 at 07:44 AM 0
Share

You should really

  1. Use code blocks here (4 spaces in front of your code lines) ins$$anonymous$$d of inline code for readability.

  2. Give proper names to your variables. It's harder to understand what you're trying to do when all your variables are called "temp".

Aside from that, I just tested this, and it works fine for me.

avatar image StonedLover · Jul 15, 2017 at 07:47 AM 0
Share

Where did you set the int ? Cause It doesnt seem like u have done it there.

You check level_compledeted for 1 then u make a string out of Level_+ levelcurrent+1 then u print it then u read the temp key into a bool but its never set so maybe thats your issue?

didnt worked much with playerPrefs so I cant say it without testing a lil bit. $$anonymous$$aybe I can say more if you provide more code

avatar image badri21 StonedLover · Jul 15, 2017 at 07:51 AM 0
Share

yes i just notified it,i used temp in double quotes,thanks.

0 Replies

  • Sort: 

Follow this Question

Answers Answers and Comments

70 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

Related Questions

Disabling function of a key 1 Answer

Using if/else statements in GUI 1 Answer

Checking nulls almost all the time! Is this normal? 1 Answer

Rotating A Camera Back and Forth 1 Answer

GUI Counter Based on Animation or RaycastHit 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