- Home /
pickup count on GUI
var coconut = 0;
function OnTriggerEnter(other: Collider) {
if (other.gameObject.tag == "coconut") {
Destroy(other.gameObject);
coconut++;
Debug.Log(honey_num);
}
}
this script works but how can i put the pickup count on my own GUI texture which i hand created in the photoshop..??
Answer by jashan · Aug 13, 2010 at 07:36 AM
You mean show the number on the photoshop texture? There's a couple of ways ... one would be writing the number over the photoshop texture; what is probably more appropriate is having one texture for each number and an array where you store the textures for all numbers. Then, you'd pick the texture from the array by "coconut" (which would act as index).
However, you'd very likely have to have a maximum number of coconuts that you can't exceed. Or, things get a little more complex: You have your own image for each digit from 0 to 9 and then build the complete number with these 0-9 textures.
do you have a maximum amount of coconuts or do you need to be able to support any number of coconuts? ;-)