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 BlueMoonGames · Jun 27, 2011 at 12:59 PM · inputtextcommandterminal

Text input command terminal

 var visible;
 var controlTexture : Texture2D;
 var gameCode : String = "1234";
 var stringToEdit : String;
 var buttonMessage : String = "Incorrect Command";
 
 function OnGUI(){
   if( visible )
   {
    stringToEdit = GUI.TextField (Rect (20, 100, 70, 25), stringToEdit, 4); 
    if(stringToEdit == gameCode){
       buttonMessage = "Begin Game";
    }else{
       buttonMessage = "Incorrect Command";
    }
    if(GUI.Button(Rect(95, 100, 95, 35), buttonMessage) && stringToEdit == gameCode){
       Application.LoadLevel ("1");
    }
 }
 }
 function Update(){
   if(Input.GetKeyDown(KeyCode.M))
   {
     visible = !visible;
   }
 }

I am trying to set up a pseudo-computer interface / command terminal (like the computer in black ops) but am unsure of how to make the text input load a level and even when the stringToEdit is equal to the gameCode, nothing happens. Could someone help me or at least guide me in the right direction. Thanks in advance

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
1
Best Answer

Answer by ckfinite · Jun 27, 2011 at 01:03 PM

Try Application.LoadLevel(1);

Comment
Add comment · Show 7 · 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 BlueMoonGames · Jun 27, 2011 at 01:09 PM 0
Share

thanks, I think the problem is with var gameCode : String = "1234"; because if ins$$anonymous$$d of gameCode in

if(stringToEdit == gameCode){

I put 1234, it works

avatar image ckfinite · Jun 27, 2011 at 01:12 PM 0
Share

Okay, I think you have already tried these, but I will go through them, just so I am in the same place as you are.

-Does anything modify gameCode?

-If you log gameCode, is it what you expect it to be?

-Have you tried trim$$anonymous$$g whitespace off the input string?

avatar image ckfinite · Jun 27, 2011 at 01:22 PM 0
Share

To go along with @Bunny83's answer, you did copy my code exactly, right? The code I posted uses a int, where the code you have now uses a string. Also, it works fine in my test project too.

avatar image BlueMoonGames · Jun 27, 2011 at 01:30 PM 0
Share

I think I found the problem, my version of Unity can not set numbers as String - I set a word as String using the exact same code posted here and it worked.

avatar image ckfinite · Jun 27, 2011 at 01:33 PM 0
Share

Numbers and characters are represented exactly the same in the string data structure. Are you using the numeric keypad for entering numbers?

Show more comments
avatar image
0

Answer by Bunny83 · Jun 27, 2011 at 01:13 PM

I'm not sure what's your actual problem, because it works in my test project...

Just make sure that the level you want to load exists. If you use a string to load a level it have to match the level name.

If you use an int it's the level index that is specified in the buildsettings

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Text Prompt Problem 1 Answer

text input without ongui? 0 Answers

Workflow for importing text files on a PC and exporting to mobile 0 Answers

Display user Input to a text UI element. 0 Answers

iPhoneKeyboard.Open cannot handle multiple entries. Is it a bug? 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