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 GraphiGames · May 21, 2016 at 05:41 AM · javascripttextscenevariableinputfield

InputField in a different scene to Text

Hey, sorry if there is a simple answer to my question, I'm a beginner in unity XD Im using 5.3. I have an InputField in my main menu scene, and in another scene I have a text gameobject which displays the InputField text.. I have added a javascript to my InputField (in my main menu scene):

  var username : String;
  var inputField : UnityEngine.UI.InputField;
  var nameDisplay : UnityEngine.GUIText;
  
  function NameInput () {
     username = inputField.text;
     nameDisplay.text = username;
     inputField.enabled = false;
  }

Since my InputField and my Text gameobject are in separate scenes, how do I assign this variable? Thanks, Sam ;) PS: What I'm trying to make is a username system similar to agar.io and slither.io where you enter your username in an inputfield in the main menu, and it appears above your player in the game scene.

Comment
Add comment · Show 3
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 GraphiGames · May 21, 2016 at 03:37 PM 0
Share

Sorry, I didnt add that script to my InputField in my main menu scene, its in my main game scene where the text is displayed ;)

avatar image Le-Pampelmuse · May 21, 2016 at 07:31 PM 0
Share

Hi. Please edit your question and remove the [Unsolved] bit. Unity Answers is different from most forums, it functions similar to stackoverflow.

It is obvious the question is unsolved because you haven't accepted any answer yet. When you (or a moderator) accept an answer, the question appears with a green background next to it. Then additionally it can be closed so it is 100% obvious the question has been processed accordingly.

avatar image GraphiGames Le-Pampelmuse · May 21, 2016 at 08:16 PM 0
Share

Okay sure ;)

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by RealMTG · May 21, 2016 at 11:44 AM

I would use PlayerPrefs and more specifically, PlayerPrefs.SetString. So in your first scene before you enter the next scene you can save your name using something like...

 PlayerPrefs.SetString("Username", inputField.text);

...where "inputField" is your username field. Then in the next scene, you can load the username variable and apply it to your text object by doing something like...

 playerName.text = PlayerPrefs.GetString("Username");

...where playerName is your text object.

Hope this helped you! :)

Comment
Add comment · Show 4 · 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 GraphiGames · May 21, 2016 at 04:01 PM 0
Share

Thanks this helps a lot, but where do I put these lines? I have not got any scripts assigned to my InputField in my main menu, only one in the main game on the text display, which is the code in my original post! Thanks ;)

avatar image RealMTG GraphiGames · May 21, 2016 at 04:08 PM 0
Share

The first one you can put right before you change scene. The last one you can put when you've created your player.

avatar image GraphiGames RealMTG · May 21, 2016 at 05:15 PM 0
Share

Its own script, or inside another one? Sorry, kinda a noob XD

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

Variable won't appear on UI text (JS) 0 Answers

Input Field Doesn't auto select in a different scene 1 Answer

Get Text from an Input Field on one scene and use it as a text on another scene Unity c# 0 Answers

Limit on GUI Components? 0 Answers

changing font + size of text 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