choose texture option when lookat
Hi, I'm trying to display different textures option when I'm looking an object, then when I look at one of the option shown the object will change his texture. I've made a c# script who change the texture when I look the object but I don't know how to display the texture as an option. Thanks in advance this is my actual script:
public class Autoselect : MonoBehaviour { public Texture[] textures; public int currentTexture;
public float timerDuration = 2f;
private float lookTimer = 0f;
private Renderer myRenderer;
private MeshCollider myCollider;
private bool isLookedAt = false;
void Start () {
}
// Update is called once per frame
void Update () {
if (isLookedAt) {
lookTimer += Time.deltaTime;
currentTexture++;
currentTexture %= textures.Length;
GetComponent<Renderer>().material.mainTexture = textures [currentTexture];
if (lookTimer > timerDuration){
lookTimer = 0f;
myCollider.enabled = false;
Debug.Log ("BUTTON HAS BEEN SELECTED!");
gameObject.SetActive (false);
}
}
else {
lookTimer = 0f;
} } public void SetGazedAt(bool gazedAt) { isLookedAt = gazedAt; } }
Your answer
Follow this Question
Related Questions
How can I set an Image (PNG) from a URL to be the material of a sphere ?? 0 Answers
Base64 to texture decoding, js -> webgl 1 Answer
Draw Curve on texture in Unity 0 Answers
Building cubemap from runtime-loaded image 0 Answers
TerrainLayer at runtime 2 Answers