En effet dans ce tutoriel , nous pouvons glisser un UI de notre Canvas Viseur via le script sur l'asset De la BoxMedical , mais impossible de le glisser à l'intérieur.
Voici le tuto : https://www.youtube.com/watch?v=yJv83oN ... f&index=11
Voici le script :
Code : Tout sélectionner
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class VieBoite : MonoBehaviour
{
public AudioClip SonVie;
public int VieValeur = 20;
public Text TxtInfos;
void OnCollisionEnter(Collision Col)
{
if (Col.gameObject.tag == "Player")
{
GetComponent<AudioSource>().PlayOneShot(SonVie);
GameObject.Find("FPSController").GetComponent<Vie>().CurVie += VieValeur;
TxtInfos.enabled = true;
StartCoroutine("Pause");
}
}
IEnumerator Pause()
{
yield return new WaitForSeconds(1f);
TxtInfos.enabled = false;
Destroy(gameObject,1f);
}
}
Merci pour votre aide.