- Home /
Problem with clearing textfield 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");
}
}
}
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Problem with clearing a textfield in every scene C#. 0 Answers
Death Counter Resets When Reloading Scene. 3 Answers
Fading To New Scene Problem? 1 Answer