[RESOLU][DB-AL] allumer et eteindre un spotlight avec une touche
Publié : 18 Mai 2018 20:59
bonjour je voudrais savoir comment allumer et éteindre un spotlight comme une lampe torche en CSharp car je ne trouve que des tutos en java ou alors je ne comprends pas. Voici ce que j'ai fais :
merci de m'aider
.
Code : Tout sélectionner
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TorchScript : MonoBehaviour {
// Use this for initialization
void Start () {
GetComponent.<light>.enabled = true;
}
// Update is called once per frame
void Update () {
if ((Input.GetKey("f")) && (GetComponent.< light >.enabled = false)
{
GetComponent.< light >.enabled = true;
}
if ((Input.GetKey("f")) && (GetComponent.< light >.enabled = true)
{
GetComponent.< light >.enabled = false;
}
}
}
.