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 Orange-Pixell · Mar 14, 2020 at 06:08 AM · level load

Unlock 2 levels which unlocks separate levels.

Imagine a map has more than one path, one level unlocks multiple levels that are on separate paths. And after they completed, each level unlocks the next level on their own paths. Can anyone help =) I found tutorials about how to unlock the next level. The problem is they created as to unlock the current and all the levels before them. Because of my level map is not a single linear system, those won't work for me.

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 JPhilipp · Mar 14, 2020 at 08:15 AM 0
Share

@Orange-Pixell Can you please show us the relevant code you already have?

avatar image Orange-Pixell JPhilipp · Mar 15, 2020 at 04:15 PM 0
Share

Sure

  public Button[] lvlButtons;
         void Start()
         {
             int levelReached = PlayerPrefs.GetInt("levelReached", 1);
             for (int i = 0; i < lvlButtons.Length; i++)
             {
                 if (i + 1 > levelReached)
                     lvlButtons[i].interactable = false;
             }
     
         }

The thing is that I have to put scenes into build in an order, I upload the levels that on one path from 1 to 5 and the levels on the other path from 6 to 11 so, if player unlocks one level on the 2nd path because that "i" will be 6 and all the levels on the first path will unlock.

I want the player to unlock levels one by one on the each path.

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by JPhilipp · Mar 15, 2020 at 04:42 PM

Think of your level unlocks as unlock ranges. Range 0 unlocks 1-5, Range 1 unlocks 6-10 and so on:


 using UnityEngine;
 
 public class LevelUnlocking : MonoBehaviour
 {
     // Define your own ranges here. Add more as you like.
     int[][] unlockRanges =
     {
         new [] {1, 2, 3, 4, 5},
         new [] {6, 7, 8, 9, 10}
     };
 
     void Start()
     {
         SetLevelButtonInteractable();
     }
 
     void SetLevelButtonInteractable()
     {
         for (int i = 0; i < unlockRanges.Length; i++)
         {
             string key = "RangeReached" + i;
             bool rangeReached = PlayerPrefs.GetInt(key, 0) == 1;
             if (rangeReached)
             {
                 for (int j = 0; j < unlockRanges[i].Length; j++)
                 {
                     int level = unlockRanges[i][j];
 
                     // Make sure lvlButtons is defined for you.
                     lvlButtons[level].interactable = true;
                 }
             }
         }
     }
 
 }
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 Orange-Pixell · Apr 19, 2020 at 06:27 AM 0
Share

Sorry for the late return. Thanx

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

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

Related Questions

Help With Level Load 1 Answer

What is best and optimized Technique of level Handling in Parking game ? loading from resources or enable in hierarchy 1 Answer

How do I load previous levels individually in the build settings in unity3d 0 Answers

UnityAds and LevelLoad Problem 0 Answers

What is the best way to detect level load on additive/asnyc level loads 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