Noticias

¡RECUERDA QUE SI ERES UN NUEVO USUARIO, DEBES PRESENTARTE PARA PODER PUBLICAR MENSAJES! | TENEMOS CANAL OFICIAL DE TELEGRAM: t.me/unity3dspain

Editar un textmesh con el teclado en playmode

Iniciado por Temugin, Octubre 11, 2015, 09:20:23 AM

Tema anterior - Siguiente tema
Octubre 11, 2015, 09:20:23 AM Ultima modificación: Enero 01, 1970, 01:00:00 AM por Temugin
Aquí es hasta donde ha llegado mi habilidad:using UnityEngine;
using System.Collections;public class CSescribirEnCasilla : MonoBehaviour {    TextMesh tmThis;
    string sPlayerName;    // Use this for initialization
    void Start () {
        tmThis = this.GetComponent<TextMesh>();
        sPlayerName = PlayerPrefs.GetString("playerName");
        tmThis.text = sPlayerName;
    }    void OnMouseDown(){
        Debug.Log("On mouse down");
        tmThis.text = "newPlayerName";
    }
} Y consigo cambiar el texto. Sin embargo lo que me gustaría hacer es permitir que el jugador introduzca su nombre (o cualquier cosa en realidad, desde escribir en carteles, ordenadores... cualquier cosa que exista en el mundo de juego), como estoy escribiendo yo ahora esta pregunta, con el teclado en tiempo real.Muchas gracias¡!

Para lo que quieres hacer puedes hacerlo con un gestor: primero necesitarías una referencia al texto que quieres editar, luego añadir un "listener", o modificar un poco esa clase que tienes creando un booleano y cuando esté activo usar el "listener".Listener: http://docs.unity3d.com/ScriptReference/Input-anyKey.html" rel="external nofollow">http://docs.unity3d.com/ScriptReference/Input-anyKey.html 

Octubre 11, 2015, 03:42:30 PM #2 Ultima modificación: Octubre 12, 2015, 05:53:18 PM por leocub58
y no es mejor usar un input field?te dejo un vídeo de mis pruebas  
eature=oembed" frameborder="0" allowfullscreen="true">

Etiquetas: