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 Jun 22, 2019 at 09:38 AM by staryzhelios for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by staryzhelios · Jun 22, 2019 at 07:38 AM · playerprefslevelstars

Why this middle code doesnt want to run, Playerpref problem

I wanted to SetActive the star3 in level button UI after play game. Unfortunatelly it only can active to 2 levels, the last level which is level 3 didnt happen. So weird. Does anyone know why?


 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine.UI;
 using UnityEngine.SceneManagement;
 
 public class LevelControl : MonoBehaviour
 {
 
 
     public Button level02Button, level03Button;
     int levelPassed;
 
     public GameObject star1, star2, star3;
 
     void Start () {
         levelPassed = PlayerPrefs.GetInt ("LevelPassed");
         
         level02Button.interactable = false;
         level03Button.interactable = false;
 
 
 
         if (levelPassed == 15) {
             level02Button.interactable = true;
             level03Button.interactable = false;
 
             star1.SetActive(true);   //WORKING
 
                 Debug.Log("Star level 1 is shown");
         }
 
         if (levelPassed == 21) {
             level02Button.interactable = true;
             level03Button.interactable = true;
 
     
             star1.SetActive(true);
             star2.SetActive(true);      //WORKING
 
            Debug.Log("Star Level 2 is shown");
 
         }
 
         if (levelPassed == 26) {
     
             star1.SetActive(true);
             star2.SetActive(true);
             star3.SetActive(true);    //NOT WORKING
 
             Debug.Log("Star level 3 is shown");
     
 // IM SURE THAT I ALREADY PASS THE LEVEL 26, WITH IS LEVEL 3. STILL STAR LEVLE 3 NOT UPDATE.

         }
 
     }
 
 
 
     public void levelToLoad (int level)
     {
         UnityEngine.SceneManagement.SceneManager.LoadScene (level);
 
     }
 
     public void resetPlayerPrefs()
     {
 
         PlayerPrefs.DeleteAll ();
     }
 
 }
 



Comment
Add comment · Show 2
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 SohailBukhari · Jun 22, 2019 at 08:02 AM 1
Share

This will be updating from another script or check console for error may be you did not passed the gameObject

avatar image staryzhelios SohailBukhari · Jun 22, 2019 at 09:33 AM 0
Share

hey man , you right! I tried checking..it drives me crazy actually. iT'S WOR$$anonymous$$ NOW. tqs alott

0 Replies

  • Sort: 

Follow this Question

Answers Answers and Comments

114 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

Related Questions

Storing in PlayerPref based on timer 1 Answer

How to make PlayerPrefs delete if the player didn't touch game finish collider 1 Answer

Value changes after using it in another script, why? 1 Answer

Accomplishments in each Level not Saving 2 Answers

PlayerPrefs Problem crashing with SetBool 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