Question by
timothy_basalo · Feb 16, 2016 at 12:55 PM ·
androidtouch controlsconverttouchscreengui.button
how to make dialog box and how can i scroll the text using UI GUI buttons in Android / Touch
So first how can i convert getkeys to touch in " if (Input.anyKeyDown(KeyCode.Return))"
i want to touch the button as a continue button. but how can i do that using UI Buttons?
using UnityEngine; using System.Collections; using UnityEngine.UI;
public class TextBoxManager : MonoBehaviour {
public GameObject textBox;
public Text theText;
public TextAsset textFile;
public string [] textLines;
public int currentLine;
public int endAtLine;
public FloatingPlayer2DController player;
void Start()
{
player = FindObjectOfType<FloatingPlayer2DController> ();
if(textFile !=null)
{
textLines = (textFile.text.Split('\n'));
}
if (endAtLine == 0)
{
endAtLine = textLines.Length - 1;
}
}
void Update()
{
theText.text = textLines [currentLine];
if (Input.anyKeyDown(KeyCode.Return))
{
currentLine += 1;
}
if (currentLine > endAtLine)
{
textBox.SetActive(false);
}
}
}
Comment