- Home /
Guitexture appear/disappear
Hello,
Frst of all sorry for my english,
I just want to know how i can appear or disappear a guitexture( it's 3 heart) when my character click on some objects
I have add a tag for each of my heart.
I have this line but i do not know how to use coe public GameObject coe = GameObject.FindWithTag("coe1");(it's for the first heart)
Thank you in advance.
Answer by Kleptomaniac · Apr 05, 2012 at 04:16 AM
So these are three GUITextures? Instead of using tags, I would use a GameObject array and then just disable elements from there. So, something like this:
var hearts : GameObject[];
private var clickCount : int = hearts.length;
function Update () {
if(Input.GetMouseButtonDown(0)){
var ray : Ray = Camera.main.ViewportPointToRay (Vector3(0.5,0.5,0));
var hit : RaycastHit;
if(Physics.Raycast (ray, hit, 100)){
if (hit.collider.tag == "click") {
hearts[clickCount].enabled = false;
clickCount--;
}
}
}
}
Simply tag the object you want to click with the 'click' and add your GUITextures to the hearts array and you're good to go. :) I think it should work, but I created on air so I'm not so sure if it will ...
Hope that helps, Klep