Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 Moonjump · Sep 11, 2010 at 04:34 PM · textiphonemacentry

high score name entry iphone

I've left high score name entry until near the end of the game as I don't quite know what to do. Maybe I read something wrong that is clouding my mind, anyway...

I have my main game game loop code that calls a HighScore () function to check if a high score has been achieved, updates the appropriate variables then goes to the Main Menu.

Currently I just have it make the player name for the score "New Score" as a placeholder.

How do I do the name entry (iPhone and Mac options)? My guess is Instantiate a new empty object that has a script calling OnGUI (something I don't use at the moment, only GUIText), that changes a nameEntry var so that I can continue my high score table updates.

I'm unsure of how to do the name entry correctly (something about OnGUI updating several times a second renewing the entry field? Is that right? maybe where I got lost).

And how do I stop the HighScore () function from continuing until I have got the name entry completed?

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

Answer by Eric5h5 · Sep 11, 2010 at 07:56 PM

You use coroutines for scheduling events:

function Start () {
    while (true) {
        yield MainMenu();
        yield PlayGame();
        if (score >= highScore) {
            yield EnterName();
        }
    }
}

In practice, the functions would probably be in other scripts, so you'd have to get appropriate references first and use them. (i.e., "yield nameScript.EnterName();")

You can use GUI.TextField for name entry. The script, which should be disabled by default so OnGUI doesn't run until needed, could be something like

private var nameEntryDone : boolean;

function EnterName () { enabled = true; // enable OnGUI function in this script nameEntryDone = false; while (!nameEntryDone) yield; enabled = false; }

function OnGUI () { // stuff with TextField if (GUILayout.Button ("Done") ) nameEntryDone = true; }

Comment
Add comment · Show 13 · 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 Moonjump · Sep 11, 2010 at 08:33 PM 0
Share

So I can stop one function until another has finished. but still in the new function, how do I stop that one until it has got a name entry? I still assume I have to create a new GameObject that contains the OnGUI that gets the name entry.

So I would have?

function HighScore () { yield NameEntry() // rest of high score code dependant on name entry }

function NameEntry () { Instantiate (nameEntryObject); ??? }

How would I fill the GUI.TextField using the iPhone$$anonymous$$eyboard? The various bits of information I have found don't seem to fit together?

avatar image Moonjump · Sep 11, 2010 at 08:34 PM 0
Share

Sorry, I didn't realise a reply lost the paragraph formatting

avatar image Eric5h5 · Sep 11, 2010 at 09:10 PM 0
Share

@$$anonymous$$oonjump: I added some code, which should clarify things. You can tap on a TextField which brings up the standard iPhone keyboard. Or you can make your own text entry + keyboard, which is a lot more work but can be totally customized.

avatar image Moonjump · Sep 11, 2010 at 09:30 PM 0
Share

Thank you Eric5h5, I understand the yield format now. The problem is still with the input. I have some code: var nameEntry = "DefaultName"; function OnGUI() { nameEntry = GUI.TextField (Rect (0, 10, Screen.width, 40), nameEntry, 31); } that I got from Unity Reference manual. This produces a box at the right time (testing on the $$anonymous$$ac version at the moment), but I cannot edit the text, even if I click on it. Plus $$anonymous$$ac / PC or iPhone I want the text entry to be active as soon as it appears. On the iPhone the keyboard should be there without the player having to tap on the TextField. Possible?

avatar image Eric5h5 · Sep 11, 2010 at 09:50 PM 0
Share

@$$anonymous$$oonjump: you might have to do your own keyboard input in that case.

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

No one has followed this question yet.

Related Questions

In-app purchase "Invalid product" on Mac Store build 0 Answers

Unity iPhone is it worth it? 2 Answers

Particles are not visible on iphone 3 Answers

Any tutorials for Unity 3 to make a TEXT BASED iphone game? 3 Answers

UnityXcode ,Mach-O linker Error 2 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