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 donimation · Dec 10, 2016 at 02:14 AM · textinputfieldresetdefault

How can I reset the placeholder of an input field back to the default readout?

Hello everyone,

I have a standard UI input field that I got from GameObject>UI

I modified the placeholder to read "PRESS TO PICK NAME" and I have a userName string that stores the name entered.

When I reset the userName to "GUEST" I want the placeholder to read "PRESS TO PICK NAME" again, but instead I still see the latest userName that was entered.

Another thing I've noticed is that when I restart the game the placeholder does read "PRESS TO PICK NAME" again.

Any ideas on to how I can get the placeholder back to the default value/text without having to restart?

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 donimation · Dec 12, 2016 at 08:08 PM

Got it!

 using UnityEngine.UI;

Create the reference container like this.. DON'T use GameObject or Text, but InputField!

 public InputField inputFieldRef;   

In the inspector make sure you drag the WHOLE inputField Layer/Group/GO not just the Text child. Then, yes this works!

 inputFieldRef.text = "";

@getyour411 I know this is what you probably meant. but I think/hope this answer might be more helpful to a Noob like me!;) Cheers!

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
1

Answer by getyour411 · Dec 10, 2016 at 02:39 AM

Create a reference to the input field.text field and set that to ""

Comment
Add comment · Show 2 · 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 donimation · Dec 12, 2016 at 06:38 PM 0
Share

@getyour411 I've been trying to do that like this:

  1. Creating a public Text inputFieldRef in my script;

  2. In the editor I drag the Text Object that is inside the inputField GO onto the script's empty slot.

  3. in my reset method I include inputFieldRef.text = "";

I've even tried to do the same for the placeholder text, but the latest name I enter still shows up.

avatar image donimation · Dec 12, 2016 at 07:47 PM 0
Share

@getyour411 hmm... I think the problem may be that I'm referencing just the Text object inside the inputField ins$$anonymous$$d of the whole inputField and then pointing to it's text. Trying to figure out the proper syntax.. [edit: in C#]

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

59 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 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

Remap keyboard/keys for InputField 0 Answers

Prevent escape key from deleting InputField contents, have it save instead? 4 Answers

Blurry text on InputField C# 0 Answers

how to use scientific values in inputfield unit or restrict only some letters 0 Answers

How to hide/reset a Text object (without disabling) 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