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
1
Question by PaulSZ4 · Sep 18, 2016 at 01:18 PM · unity5beginnerlevel loadlevel select

How can I lock a Level?

Hello, I'm making my first game in Unity, it's a 2D runner. I have created some levels and at the end of each level, there's a box that unlocks the next level and loads it. But, the problem is, the player can load the locked levels. What I have done: 1. Created a button for each level. 2. Made a lock texture and added it on each level. 3. When the player finishes say level 1 (hits the box I mentioned above), the next level will be unlocked and lock is no longer active. But even if the lock is active, the player can still load the level and I need to prevent this from happening. Any help, please? If you can provide explanation too, that'd be great. I'm still very new to Unity. Thanks. Level manager script: alt text Levels Select scene: alt text Link for the tutorial I used for the script: https://www.youtube.com/watch?v=hn20gIg4Gao

14258183-319098648445113-7920661139891253981-o.jpg (101.4 kB)
14372127-319098668445111-8874585952533026762-o.jpg (137.1 kB)
Comment
Add comment
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

2 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by Padalino · Sep 18, 2016 at 01:29 PM

Simple. If your level is locked, just disable the button, and the player won't be able to click it. You can do it with this line: button.GetComponent .enabled = false; If the level is unlocked, do the same, but instead of enabled = false, set it to true.

Hope that solved your question. If not, let me know and I'll try to help you.

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 TUTOCF · May 09, 2017 at 07:35 PM 0
Share

Thanks but do you know how to save a boolean with PlayerPrefs ?

avatar image
0

Answer by italhaali88 · Nov 25, 2021 at 01:40 PM

Use Playerprefabs and set interactable to false
set first one interactable to true;

Comment
Add comment · 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

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

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Level Selector not working on build 0 Answers

How to make an exit level trigger? 3 Answers

How to load scenes based on specific percentage? 0 Answers

manage objects through a manager script 0 Answers

how do I instantiate random gameobject every certrain meters the player moves? 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