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 LMK21 · Nov 15, 2014 at 02:28 AM · c#scenetextfieldtextarea

Problem with clearing a textfield in every scene C#.

So, in a nutshell:

I have two scenes. We'll call them SceneX and SceneY.

In SceneX you see a textfield. You write, let's say, "SCENEY" in it and you can move on to the SceneY.

When you enter SceneY you see yet another textfield. Same as in SceneX. You have to once again write something in it, let's say in this case "SCENEZ" to move on to the next scene. However, when you tap the textfield it shows the text "SCENEY" that we wrote in SceneX. Unless you lock your phone and reopen it the text won't disappear and you are unable to write new text.

It only happens on phone (Android). In Unity game mode everything works perfectly. So what to do? The code is rather simple and presented below

 using UnityEngine;
 using System.Collections;
 using System;
 public class Game : MonoBehaviour {
 string textToEdit = "";
 public GUISkin customSkin;
 void OnGUI()
 {
 GUI.skin = customSkin;
 textToEdit = GUI.TextField (new Rect (100, 190, 260, 50), textToEdit, 30);
 }
 // Use this for initialization
 void Start ()
 {
 }
 // Update is called once per frame
 void Update ()
 {
 if (textToEdit == "PASSWORD")
 {
 Application.LoadLevel ("scenez");
 }
 }
 }
  


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
0

Answer by zharik86 · Nov 15, 2014 at 07:41 AM

For android device try add:

  private TouchScreenKeyboard keyboard;

  void Start() {
   //Use platform dependent
   #if UNITY_ANDROID
    keyboard = TouchScreenKeyboard.Open("");
    keyboard.active = false;
   #endif
  }

I hope that it will help you.

Comment
Add comment · Show 3 · 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 LMK21 · Nov 15, 2014 at 01:26 PM 0
Share

Zharik86 thank you so much!

avatar image zharik86 · Nov 15, 2014 at 07:39 PM 0
Share

@L$$anonymous$$$$anonymous$$21 if I helped you, please, mark my answer (below vote button).

avatar image meat5000 ♦ · Nov 19, 2014 at 04:43 PM 0
Share

Its just a case of having not entered a blank string before the next usage.

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

2 People are following this question.

avatar image avatar image

Related Questions

GUILayout.TextArea/TextField not working. 1 Answer

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

Problem with clearing textfield C#. 0 Answers

Add GUI elements to Scene View? 3 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