LeanTween.delayedCall BroadcastMessage loadtips has no receiver

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.

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.

The 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

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} );

The JS version worked for me--thanks! So does this mean that if I pass that function in without quotes, I don't need to have the function attached to gameobject I'm tweening? In all the other LeanTweens I've run, I haven't attached the script to the game object that I'm tweening, so I'm just wondering when I should be doing so.

That is correct, it figures out the scope of the function all by itself. If you want to have a function called on the gameobject itself you could do something like: LeanTween.delayedCall (overlay,5.0, overlay.GetComponent(ScriptName).loadtips );

Thank you for the clarification! On a different note, I think there may be a typo in the [documentation][1] for your LeanTween.alpha and LeanTween.alphaVertex since both the "to" and the "time" say "The time with which to delay before calling the function." I wasn't sure where to flag that for you, in case you wanted to update it. Thank you [1]: http://dentedpixel.com/LeanTweenDocumentation/classes/LeanTween.html

Oh wow, I must have been half asleep when I wrote the documentation for that piece, there were a bunch of incorrect information there. Thanks for the heads up. It will be updated the next time push up new documentation.

Glad to give you the heads up and thanks for being open to it. Looking forward to the update!

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;
}