I’m creating 3d TextMesh and when I change the text it changes the text for all of the meshes. I’m at a loss because I’m not even using public variables, let alone static.
Here’s my script:
public class TextObject : MonoBehaviour {
private string text = "Hello World";
private int tapCount = 0;
private float tapWindow = 0;
private TouchScreenKeyboard keyboard;
// Use this for initialization
void Start () {
keyboard = TouchScreenKeyboard.Open (text, TouchScreenKeyboardType.ASCIICapable, false, false, false, false, text);
}
// Update is called once per frame
void Update () {
if(tapWindow > 0f)
{
tapWindow -= Time.deltaTime;
if(tapCount >= 2)
DoubleTapped ();
}
// if(keyboard.active)
// text = keyboard.text;
if(keyboard.done)
{
text =keyboard.text;
GetComponent<TextMesh>().text = text;
if(text == "")
{
Destroy(gameObject);
}
}
}
public void SwitchMode()
{
tapCount++;
tapWindow +=1f;
}
public void DoubleTapped()
{
keyboard = TouchScreenKeyboard.Open (text, TouchScreenKeyboardType.ASCIICapable, false, false, false, false, text);
}
}
I removed some parts of the script because they’re easily not related (Destroy, for instance). However, this is probably 95% of the script. What am I missing?