I have a small task. That is very small task but there is i don’t know the error where it is.
By default my texture is on position. I want that into disable.
i wrote code like this:
var someTexture : Texture2D;
function Update () {
if (Input.GetKeyDown ("space")){
if (someTexture.enabled == true){
someTexture.enabled = false;
}
else {
someTexture.enabled = true;
}
}
}
My problem here is, I attached this script to main camera and added texture in the inspector of the main camera. After then play mode. Nothing will be getting in the game scene. what can i do? i want by default that texture is in show in game scene and if i press space button that will disable .and again i press space button i want to display.
I have same problem, and I discover this way is also fine
var showHPBar:GUITexture;
var MaxHP:int = 1000;
var HP:int = 500;
function Update(){
showHP();
}
function showHP(){
if(MaxHP != HP){
showHPBar.gameObject.SetActive(true);
}
}