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
0
Question by Zeretyh · Feb 05, 2016 at 04:47 PM · loadbooleanif-statements

If statement fails...

Hi,

I can't find the reason why the first if statement gets executed when I am loading another scene. Even though I am making sure that game1done is true, and checker is !=17, the if() is still being executed a second time, when the user press a button doing a Loadlevel()

Any ideas? Thanks

if ( game1done == false && checker == 17){

             checker = 24;
             Debug.Log("setting 11 CALLED");
             Debug.Log ("game 1 is " + game1done);
             Debug.Log ("game 2 is " + game2done);

             timeLeft = timerTime;
                 
                 Debug.Log ("start game 2");

                 //give one star and save it
                 //Set pref 11

                 PlayerPrefs.SetInt (theday, 11);
                 star1.sprite = StarGet;
                 game1done = true;



         } 

         else if (game1done == true && game2done == false  ) {
                 

             PlayerPrefs.SetInt (theday, 12);
             int dayValueB = PlayerPrefs.GetInt (theday);
             Debug.Log ("DayValue of"+ theday + "is : " + dayValueB);

             game1done = true;    
             game2done = true;
                 //button game 3
                 //GameObject button3 = GameObject.Find ("game3");
                 //ExecuteEvents.Execute (button3.gameObject, pointer, ExecuteEvents.pointerClickHandler);
 
                 timeLeft = timerTime;
                 Debug.Log ("start game 3");
             Debug.Log ("game 1 is " + game1done);
             Debug.Log ("game 2 is " + game2done);


                 
             //only happens when the game 2 is done...

             star2.sprite = StarGet;

         }
Comment
Add comment · Show 4
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 Light997 · Feb 06, 2016 at 11:21 AM 0
Share

Could you maybe edit your question to show the entire script?

avatar image NoseKills · Feb 06, 2016 at 02:37 PM 0
Share

As @Light said, we need to see where and when you are setting those variables and when you make the if-check so we can try to guess why the variables have different values from what you think they have :)

avatar image Light997 NoseKills · Feb 06, 2016 at 02:39 PM 0
Share

@Nose$$anonymous$$ills Thanks for expressing this more clearly :)

avatar image mohaaaaamed · Feb 06, 2016 at 02:58 PM 0
Share

did you check in the inspector if the variables changed cause it's impossible to get executed if the variables didn't changed give FULL script

0 Replies

· Add your reply
  • Sort: 

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

42 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

Related Questions

&& if-statement not working 0 Answers

bool not properly working and time counter only adding once 1 Answer

How to turn turn off/on a collider with a boolean from another script 1 Answer

AudioSource in Update 1 Answer

Help with bools and if else statements. Animations 2 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