Witam. Tworzę swoją pierwszą grę i chciałem zrobić wyświetlanie podpowiedzi, ale pojawia mi się błąd, gdy takowy ma się wyświetlić. Pojawia się coś takiego:
"SendMessage tipDisplayMessage has no receiver!
UnityEngine.Component:SendMessage(String, Object)
TipCollider:OnTriggerEnter(Collider) (at Assets/TipCollider.cs:8)"
Chciałem zrobić, żeby skrypt z jednego obiektu korzystał z innego skryptu drugiego obiektu. Poniżej są oba skrypty:
using UnityEngine;
using System.Collections;
public class TipCollider : MonoBehaviour {
void OnTriggerEnter(Collider other)
{
other.SendMessage("tipDisplayMessage", "Your TIP!");
}
}
using UnityEngine;
using System.Collections;
public class TipDisplayer : MonoBehaviour
{
private bool showTip = false;
private float timer = 0;
public GUIText tipGUI;
public float tipTime = 5;
void displayTipMessage(string tipText)
{
tipGUI.text = tipText;
tipGUI.enabled = true;
this.showTip = true;
}
void Update()
{
if (showTip)
{
if (timer < tipTime)
{
timer += Time.deltaTime;
}
else
{
tipGUI.enabled = false;
showTip = false;
timer = 0;
}
}
}
}