I’m using trying to call a function with a delay using LeanTween, but get this error “BroadcastMessage loadtips has no receiver!
UnityEngine.GameObject:BroadcastMessage(String)”
The code is
LeanTween.delayedCall (overlay,5.0,“loadtips”);
I’ve verified that the function loadtips is working.
2 Answers
2
This is probably due to the “loadtips” function not being on the gameobject you are tweening (which it defaultly assumes, when you pass the function as a String).
if you are working in javascript you can just pass the function without the quotes and it should work like:
LeanTween.delayedCall (overlay,5.0,loadtips);
In C Sharp you have to be more explicit, and pass a variable “onCompleteTarget”, like:
LeanTween.delayedCall (overlay,5.0,"loadtips", new object[]{"onCompleteTarget", this} );
Here an example that works for me:
if (LeanTween.isTweening(placarFundoRect) == false && placarFundoInteragir == true)
{
Vector2 orig = new Vector2(0.5f * Screen.width - placarFundo.width * 0.5f, 0.5f * Screen.height - placarFundo.height * 0.5f);
htb = new Hashtable(); htb.Add("ease", LeanTweenType.easeOutBounce); htb.Add("onCompleteTarget", this.gameObject); htb.Add("onComplete", "somPlacar");
LeanTween.move(placarFundoRect, new Vector2(1.0f * Screen.width + placarFundo.width, placarFundoRect.rect.y), 2f, htb);
htb = new Hashtable(); htb.Add("ease", LeanTweenType.easeOutBounce); htb.Add("delay", 1.0f);
LeanTween.move(placarFundoRect, orig, 1.0f, htb);
}
The internal function that I called above:
void somPlacar()
{
tocarSom(placarFundoBateu);
placarAboboraInteragir = true;
}
Are you 100% certain that your overlay object or one of it's children has the script attached containg the loadtips() function? That error is basically telling you that there is no GameObject with a function named loadtips to be found.
– Keith1024The overlay object doesn't have the script attached, but the solution that dentedpixel suggested worked: passing that function in without quotes, without having the function attached to gameobject I'm tweening
– unitygal