I’m just wanting some text to appear on the screen as I’m making a 2D still image game. But of course I need certain text to appear when clicking certain positions in X,Y,Z. Any ideas?
Huh? You can’t convert a string to a bool. I’m not really sure what evaluation that would do anyway.
OnGUI is called automatically for every MonoBehaviour in the scene if it contains such a method. You can check for mouse click input in Update() which is also automatically called. Beyond that your question isn’t really clear.
I’m sorry if it wasn’t clear. But basically what I’m trying to do is have some text appear on the screen at a position I set. When clicking on a certain part of the screen. I thought this may of been the function I was looking for. I’ll look for something else that may work for what I need. Thanks
Also rather then just creating a text field on the screen then just coding in what to write in the box when clicking certain things. I was thinking about having the code create the text field, position at the coordinates I set and write what I want inside. Make sense?
using UnityEngine;
using System.Collections;
public class WindowShow : MonoBehaviour {
public string stringToEdit = "";
void OnGUI() {
stringToEdit = GUI.TextArea(new Rect(10, 10, 200, 100), stringToEdit, 200);
}
// Use this for initialization
void Start ()
{
}
// Update is called once per frame
void Update ()
{
if(Input.GetMouseButtonUp(0))
{
stringToEdit="Hi";
}
}
}
I guess like this, Not sure if it’s the best way of going about it. But obviously now I’d include different things to write depending on what part of the screen you click on.