• 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 Skflowne · Jul 23, 2014 at 11:48 AM · guiloginpasswordpasswordfield

How to make a login screen without input bar and without having to press enter on password field?

Hi, I am really struggling with t$$anonymous$$s because of the behavior of the PasswordFieldcomponent that won't let me retrieve the string if the user doesn't press done on the mobile keyboard.

Basically I need the PasswordField to behave like the Textfield component so that when the user touches the login Button my app can directly send both fields even if the user hasn't pressed done on the mobile keyboard.

Is there any way to make t$$anonymous$$s happen ?

Edit : Right now I have t$$anonymous$$s code w$$anonymous$$ch works fine in the editor but no on mobile

 public class Textfield : SquaredMenuElement, IMenuElement {
 
     public string defaultText = "";
     public bool isPasswordField = false;
     public static bool inputHidden = true;
     public GUIStyle style = new GUIStyle();
 
     public static Dictionary<string, string> textValues = new Dictionary<string, string> ();
 
     private string stringToEdit;
 
     protected override void Awake(){
         base.Awake ();
         stringToEdit = defaultText;
         TouchScreenKeyboard.$$anonymous$$deInput = inputHidden;
     }
 
     void Update(){
         Debug.Log( gameObject.name + " : " + stringToEdit + " focus : " + GUI.GetNameOfFocusedControl() );        
     }
     
     void OnGUI(){
 
 
         if(!isPasswordField){
             GUI.SetNextControlName(gameObject.name);
             stringToEdit = GUI.TextField ( position, stringToEdit, style);
         } else {
             GUI.SetNextControlName(gameObject.name);
             stringToEdit = GUI.PasswordField( position, stringToEdit, '*', style);
         }
 
         if(GUI.GetNameOfFocusedControl() == gameObject.name && stringToEdit == defaultText){
             stringToEdit = "";
         }
         
     }
 
     public string GetText(){
         return stringToEdit;
     }
 }

The problem is, on mobile (android at least, didn't try ios), when I have two of my custom Textfield, whenever one gets the focus the value of the other is copied into it for some reason. Also t$$anonymous$$s doesn't happen if you comment the line TouchScreenKeyboard.$$anonymous$$deInput = inputHidden;

Comment
Add comment · Show 2
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 Landern · Jul 23, 2014 at 01:00 PM 0
Share

I'm only asking the below since you state:

The problem is, on mobile (android at least, didn't try ios), when I have two of my custom Textfield, whenever one gets the focus the value of the other is copied into it for some reason.

The above script, do you use it once for the controls? If you do, don't use a reference object (stringToEdit) for both fields since it points to the same object. If you don't, there is likely a bug, since it's not static (stringToEdit), the reference should be different if you use two instantiated objects that are of this type.

avatar image Skflowne · Jul 24, 2014 at 09:23 AM 0
Share

I do use the same prefab for my textfields but they have their own instances in the scene, the hierarchy is like this : Interface -> LoginMenu -> ( LoginField, PasswordField, LoginButton )

I suspect the problem comes from the keyboard which seems to become static instead of per field when you use TouchscreenKeyboard.hideinput

0 Replies

· Add your reply
  • Sort: 

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

23 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

Related Questions

Creating a Password Field 1 Answer

why can I not log in using my email and password? 2 Answers

Gui Login With Interface 1 Answer

How to make a Keypad for a locked door 2 Answers

Checking a hash with random salt 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