- Home /
Disable gui texture in a different way?
Hi, I have a script and 4 gui textures. The first two just do this: guitexture.enable = true/false and the other two write in the log if they were pressed. The first two will enbale/disable one of the two other textures so that only one is seen but the problem is they still react if one touches them even though they cannot be seen. How do I disable a guitexture so it wont react when pressed? This only hides it.. var dollar : GUITexture; var book : GUITexture;
function Start () {
ceo = GameObject.Find("ceo").guiTexture;
writer = GameObject.Find("writer").guiTexture;
mainoffice = GameObject.Find("mainoffice").guiTexture;
scriptroom = GameObject.Find("scriptroom").guiTexture;
dollar = GameObject.Find("dollar").guiTexture;
book = GameObject.Find("book").guiTexture;
}
function Update () {
for (var touch : Touch in Input.touches){
if (touch.phase == TouchPhase.Stationary){
if (book.HitTest (touch.position)){
mainoffice.enabled = false;
ceo.enabled = false;
scriptroom.enabled = true;
writer.enabled = true;
}}}
for (var touch : Touch in Input.touches){
if (touch.phase == TouchPhase.Stationary){
if (dollar.HitTest (touch.position)){
mainoffice.enabled = true;
ceo.enabled = true;
scriptroom.enabled = false;
writer.enabled = false;
}}}
for (var touch : Touch in Input.touches){
if (touch.phase == TouchPhase.Stationary){
if (ceo.HitTest (touch.position)){
mainoffice.enabled = true;
ceo.enabled = true;
scriptroom.enabled = false;
writer.enabled = false;
}}}
for (var touch : Touch in Input.touches){
if (touch.phase == TouchPhase.Stationary){
if (writer.HitTest (touch.position)){
mainoffice.enabled = true;
ceo.enabled = true;
scriptroom.enabled = false;
writer.enabled = false;
}}}
}
An easy way would be to rewrite your checks:
if (book.enabled && book.HitTest (touch.position))
if (dollar.enabled && dollar.HitTest (touch.position))
if (ceo.enabled && ceo.HitTest (touch.position))
if (writer.enabled && writer.HitTest (touch.position))
Your answer
Follow this Question
Related Questions
Android touch and drag GUItexture problem 0 Answers
android touch input 1 Answer
Executing Code Once Per Touch 1 Answer
Android car controls c# 0 Answers
Android touch gui help!!! 2 Answers