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 Zitoox · Jul 08, 2016 at 01:29 AM · script.scene-switchingkeycodeonwords

Open scene by typing a word

I know that it's possible to open/change a scene using scripts,like Click on buttons or pressing a keyboard key, or even using the mouse buttons.

But, is it possible to open/change a scene in game by tipping a word? For example "TEST". When player types "TEST" in the keyboard, he is automatically moved to a new scene, like a cheat code. Is this possible? And if it is, what i need to do to make a script that work in this way?

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

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

Answer by Firedan1176 · Jul 08, 2016 at 01:45 AM

All you need is an InputField. All you need to do is add a method to when the text is changed, under the TextField component. You'll also want to detect when they press enter, so they can finish typing it before confirming they want to load that level. Then, all you need to do is load the level with the string that is provided.

Edit

In your scene, create an InputField. Add a C# script called LoadLevelCheatCode. In the code, type this:

 using UnityEngine;
 using UnityEngine.SceneManagement;
 using System.Collections;
 
 public class LoadLevelCheatCode : MonoBehaviour {
 
     public string cheatcode = "tilt";
 
     public void SubmitCode(string code) {
         if (code.Equals(cheatcode) && SceneManager.GetSceneByName(cheatcode) != null) SceneManager.LoadScene(cheatcode);
     }
 }

In the script you put on the InputField, fill in the "Cheatcode" field with the level name. It must match case too. Then, on the InputField component, under the "End Edit" field, add one. Drag the C# script you made into the target field. That's it! If you still need help, just leave another comment. You can also personally contact me on Skype: Firedan1176 if you have other questions, or want a more instructive way to do this.

Comment
Add comment · Show 3 · 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 Zitoox · Jul 08, 2016 at 01:48 AM 0
Share

I found and updated a script that i found but i can't get it to work, i think it's because of the Unity 5

Here's the question: http://answers.unity3d.com/questions/1213131/problem-with-cheatcode.html

avatar image Firedan1176 Zitoox · Jul 08, 2016 at 03:35 AM 0
Share

Are you wanting the cheatcode to be activated as soon as they type in tilt, or do they need to press 'enter' to submit it?

avatar image Zitoox Firedan1176 · Jul 08, 2016 at 05:26 PM 0
Share

As soon as they type tilt.

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

45 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

Related Questions

Increase when the Key is Down and Decrease when the Key is Up 2 Answers

Word Brain Scramble word script ? 0 Answers

Change camera viewport rect via script 1 Answer

Does anyone know how to look into this sort of thing? (Desciption) 3 Answers

Automatic Scene Switch Script? 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