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 May 12, 2018 at 08:12 PM by TheIronSpike for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by TheIronSpike · May 10, 2018 at 09:27 AM · level select

Help with level unlock sysyem

so I tried to make a level unlock system that uses ints and I thought it would work but it says "NullReferenceException: Object reference not set to an instance of an object finish.Start () (at Assets/Scripts/finish.cs:42)"

What I did is in the code below and the script is on my finish trigger and my canvas in my level selector.

I created public buttons and assigned all of them on my level selector but when I go back to level 1 it has all of the slots like I thought. When I hit play it said that error up above. I did not set any of the buttons slots on the inspector to anything because I did not have anything to put on it. and some of the code will have my finish trigger stuff in it. HELP!! EDIT:I have filled all of the buttons with buttons that are turned off but when i complete a level and go back to a menu it still doesn't have level 2 unlocked. NEED BIG HELP!!

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine.SceneManagement;
 using UnityEngine.UI;
 
 public class finish : MonoBehaviour {
 
     public int scene = 1;
     public int unlockedlevel = 0;
 
     public GameObject LevelComplete;
 
     
     public Button button2;
     public Button button3;
     public Button button4;
     public Button button5;
     public Button button6;
     public Button button7;
     public Button button8;
 
     
 
 
 
 
     private void OnTriggerEnter()
     {
         LevelComplete.SetActive(true);
         
         if( scene >= unlockedlevel)
         {
             unlockedlevel = unlockedlevel + 2;
         }
 
     }
 
 
     private void Start()
     {
         button2.interactable = false;
         button3.interactable = false;
         button4.interactable = false;
         button5.interactable = false;
         button6.interactable = false;
         button7.interactable = false;
         button8.interactable = false;
 
         Invoke("Unlocked", 2f);
     }
 
 
     public void Unlocked ()
     {
         if(unlockedlevel >= scene)
         {
             button2.interactable = true;
         }
     }
 
 
 }




This is my level 1 Trigger inspector: alt text

inspectorforlevel1.png (49.9 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

1 Reply

  • Sort: 
avatar image
0
Best Answer

Answer by tormentoarmagedoom · May 09, 2018 at 09:58 PM

Good day.

First, read some questions before coming to ask. and try to find the answer in the forums.

Second, If want help, help us by explaining what you need, what you have, and what you tried before coming to ask for help.

Third, please remake the question giving more information, showing some screenshot to help people give you a correct answer.


Good day again.

I think you need a very basic learning.... You are not traspassing information between scenes. When you change scene, all from last scene is destroyed, and instantiated all new scene as new.

Go learn the first part of this Unity tutorial about SAve data between scenes

Bye.

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 TheIronSpike · May 10, 2018 at 12:43 AM 0
Share

Thanks, I looked up some and I found out that you can use ints so I tried to do it and it did not go so well so if you can take a look at it that would be great!

Follow this Question

Answers Answers and Comments

81 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

Related Questions

Level select design approaches. 0 Answers

Add GameObject to List using Timer 1 Answer

At my 3 star rating system per level the sprite only changes for one image at a time why? 3 Answers

level selection using gui.SelectionGrid 2 Answers

Load scene transistions 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