• 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: 

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

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

PlayerPrefs Problem crashing with SetBool 2 Answers

Level stars on levels menu 1 Answer

How can I collect playerprefs values? 0 Answers

Why does my level progress reset after clicking the level menu button but doesnt reset after clicking the lvel menu button from the win screen? 1 Answer

Dynamic Star System with PlayerPrefs 1 Answer


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