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:
//TipDisplayer
using UnityEngine;
using System.Collections;
public class TipDisplayer : MonoBehaviour {
private bool showTip = false;
private float timer = 0;
public float tipTime = 5;
public GUIText tipGUI;
void Update ()
{
if(showTip)
{
if(timer<tipTime)
{
timer += Time.deltaTime;
} else{
tipGUI.enabled = false;
showTip = false;
timer = 0;
}
}
}
void displayTipMessage(string tipText)
{
tipGUI.text = tipText;
tipGUI.enabled = true;
this.showTip = true;
}
}
//TipCollider
using UnityEngine;
using System.Collections;
public class TipCollider : TipDisplayer {
void OnTriggerEnter(Collider other)
{
other.SendMessage("tipDisplayMessage", "Your Tip!");
}
}