how can I make an if statement with an array that contains texture?
eg: I want every time I click on an item with texture I delete it.
function OnMouseDown(){
if(renderer.material.mainTexture == [1]){
Destroy(gameObject);
}
}
Just simply:
function OnMouseDown(){
if(renderer.material.mainTexture){
Destroy(gameObject);
}
}
should do.
does not work, then how can I say that the object can be deleted when it is red? In the array, the red color is the element 5. thanks
to get destroyed those with red color:
if(renderer.material.color == Color.red)
but all the objects to be destroyed like that must have this script as well as the collider attached.
Possibly you could attach the list of colors and the list of textures to the script.
and then delete the object
if(colorList.Contains(renderer.material.color))
or
if(textureList.Contains(renderer.material.color))
you have both the script that the collider. I envi texture object that changes every 5 seconds so I did a random array. But I want that the object is clickable by the mouse when it becomes red (the number 4 position in the array)