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 /
  • Help Room /
avatar image
0
Question by PegasiStudios · Jan 19, 2016 at 09:39 AM · loadingsavingloadlevel

How do I make a level code system?

I'm wanting to make the loading of a level like it used to be in the nes days. this was by entering in a code that the game would give you and it would take you to the level. how would i do this? I have an empty level set up with an input field.

Comment
Add comment · Show 1
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 brunocoimbra · Jan 20, 2016 at 01:49 AM 0
Share

Could not reply your comment, so...

Unity have the "Input Field" (you can create it with the right click in the hierarchy window, under the canvas menu.

To do what you want, just do something like that:

 var inputFiled : InputField
 var yourString : String
 
 function InputEnd()
 {
     yourString = inputField.text;
 }

In the inputField reference, just drag and drop the InputField that you just created, then call that function by the InputField (it has an section "OnInputEnd" or something like that, just select that script, then). It should pick correctly the string typed by the player.

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by fffMalzbier · Jan 19, 2016 at 09:46 AM

In the simplest case, after the user ended his input ( On End Edit event) check in a loop against the code values for the different levels and if the input is matching the level code you can load the corresponding level. From that base you can expand it in the artistic direction you like.

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

Answer by White8eard · Jan 19, 2016 at 09:55 AM

 if(inputcode==levelcode)
 {
    SceneManager.LoadScene("levelname");
 }

predefine the levels based on levelcode..then compare it with input code.

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

Answer by ForeignGod · Jan 19, 2016 at 09:55 AM

Several ways of doing this, depends on your needs really. This should work to some extent atleast.

     if(yourString.Contains("YourLevelCode"))
        {
        //logic
        Application.LoadLevel("x")
        }

http://docs.unity3d.com/ScriptReference/String.html http://docs.unity3d.com/ScriptReference/Application.LoadLevel.html

Comment
Add comment · Show 5 · 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 PegasiStudios · Jan 19, 2016 at 09:37 PM 0
Share

It says $$anonymous$$ Identifier: YourString

avatar image brunocoimbra PegasiStudios · Jan 19, 2016 at 10:25 PM 0
Share

lol, "yourString" should be replaced with the string you are getting from player's input...

avatar image PegasiStudios brunocoimbra · Jan 19, 2016 at 10:37 PM 0
Share

oh. Im sorry im such a noob at this kind of stuff i also made a follow up question. http://answers.unity3d.com/questions/1129963/level-code-script-not-working.html i dont know if its correct though :/

Show more comments
Show more comments

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

6 People are following this question.

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

Related Questions

Pickup number of objects and have another object appear? 2 Answers

Do we have to open SavedGame every time we do a CommitUpdate when using cloud PlayGames services? 1 Answer

what are some common stratagies for loading assets in unity? 0 Answers

Playerprefs don't work on Android 0 Answers

Setting components variables with another component 0 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