Well i have no clue on how to code in C# but this what i got:
using UnityEngine;
using System.Collections;
public class NVGoff : MonoBehaviour {
private GUITexture gui;
// Update is called once per frame
void Update () {
if(Input.GetKeyDown("n") ) {
guiTexture.enabled = false;
}
else
guiTexture.enabled = true;
}
}
So basically at :
}
else
guiTexture.enabled = true;
}
how can i make that enable the guitexture till i press n again?
var tmpTexture : Texture2D;
var boolDrawTexture : boolean = false;
function Update(){
if(Input.GetKey(KeyCode.N)){
if(boolDrawTexture){
boolDrawTexture = false;
} else{
boolDrawTexture = true;
}
}
}
function OnGUI(){
if(boolDrawTexture)){
GUI.DrawTexture(Rect(25, 25, 200, 100), tmpTexture);
}
}
sorry , its in JS , but its really not to hard to translate this one i would suspect.
o haha , i just realised , your not using regular textures , it was a gui texture , sorry , will repost in a bit here.
var tmpTexture : GUITexture;
var boolDrawTexture : boolean = false;
function Update(){
if(Input.GetKey(KeyCode.N)){
if(boolDrawTexture){
tmpTexture.enabled = true;
boolDrawTexture = false;
} else{
tmpTexture.enabled = false;
boolDrawTexture = true;
}
}
}
** Also , i didnt use keydown , change that up , but yea it works the same way , pretty simple. I added this script to the GUITexture object in the scene , and assigned the GUITexture object to the variable it exposes , works fine. Toggles on and off. (Actually in my case , if you hold the button , it does it over and over real fast, but you can use your keyDown to fix that no problem.
Alrighties, thank you sir!
or add in a timer and have it toggle over time