
Hum...
Malheureusement quelque chose ne fonctionnait pas en l'état,
voici le message d'erreur qu'il m'affiche :
NullReferenceException: Object reference not set to an instance of an object
UnityEditor.Graphs.Edge.WakeUp () (at <8114aacb458543f0950a244ad87770c8>:0)
UnityEditor.Graphs.Graph.DoWakeUpEdges (System.Collections.Generic.List`1[T] inEdges, System.Collections.Generic.List`1[T] ok, System.Collections.Generic.List`1[T] error, System.Boolean inEdgesUsedToBeValid) (at <8114aacb458543f0950a244ad87770c8>:0)
UnityEditor.Graphs.Graph.WakeUpEdges (System.Boolean clearSlotEdges) (at <8114aacb458543f0950a244ad87770c8>:0)
UnityEditor.Graphs.Graph.WakeUp (System.Boolean force) (at <8114aacb458543f0950a244ad87770c8>:0)
UnityEditor.Graphs.Graph.WakeUp () (at <8114aacb458543f0950a244ad87770c8>:0)
UnityEditor.Graphs.Graph.OnEnable () (at <8114aacb458543f0950a244ad87770c8>:0)
J'ai mis un debug log pour voir.
Code : Tout sélectionner
using UnityEngine;
using TMPro;
public class Panel : MonoBehaviour
{
// Le champ est statique, donc commun à toutes les instances de Panel.
public static int FoundPanels;
[SerializeField] private TMP_Text foundPanels;
private void OnTriggerEnter2D(Collider2D collision)
{
if (collision.CompareTag("Player"))
{
Debug.Log("ok");
// Met à jour le nombre de panneaux trouvés.
FoundPanels++;
// Met à jour l'UI.
foundPanels.text = FoundPanels.ToString();
// Détruit le panneau au bout de 1/2 seconde.
Destroy(gameObject, 0.5f);
// Désactive le panneau.
gameObject.SetActive(false);
}
}
}
ça m'a appris que la collision ne se faisait pas
j'ai donc utiliser une autre méthode pour détecter la colision
Code : Tout sélectionner
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using TMPro;
public class Panel : MonoBehaviour
{
// Le champ est statique, donc commun à toutes les instances de Panel.
public static int FoundPanels;
[SerializeField] private TMP_Text foundPanels;
void OnTriggerEnter2D(Collider2D other)
{
PoupouleControle controller = other.GetComponent<PoupouleControle>();
if (controller != null)
{
Debug.Log("ok");
// Met à jour le nombre de panneaux trouvés.
FoundPanels++;
// Met à jour l'UI.
foundPanels.text = FoundPanels.ToString();
// Détruit le panneau au bout de 1/2 seconde.
Destroy(gameObject, 0.5f);
// Désactive le panneau.
gameObject.SetActive(false);
}
}
}
El la ça marche
(même si l'étrange message d'erreur est toujours présent)
merci pour votre aide et pour le temps que vous m'avez accordé pour régler mon problème