- Home /
"Send Message Has No Receiver" On Button Click
I am creation button object using prefab and assign component to it as like following.
GameObject buttonInstane = CreateButton (cellPosition, unlockedPuzzlePref);
buttonInstane.GetComponent<PuzzleInformation>().puzzleId = puzzleCounter;
tk2dButton buttonScript = buttonInstane.AddComponent("tk2dButton") as tk2dButton;
buttonScript.targetObject = gameObject;
buttonScript.messageName = "OnPuzzleButtonClick";
Following image demonstrate component that I run time created.
Created button was show correct data in inspector. Buttons gameobject added as target and OnPuzzleButtonClick method name added as message.
Inspite of this correct output, I got following error message in console on click of button.
Please someone help me to correct this problem.
Answer by Ed unity · Mar 11, 2014 at 06:00 PM
You should take a look at this post. It sounds like you are having the same issue with prefabs vs instantiated objects.
http://answers.unity3d.com/questions/281955/sendmessage-has-no-receiver-1.html
Thanks for you help. But at this point, I don't call send message manually it was performed by tk2d.
Do "Buttons" (the gameObject your sending the message to) have a function called "OnPuzzleButtonClick". If it doesn't, this is your problem. Also, the gameObject "Buttons" must have this function in a script connected to THAT object - not any child objects
Your answer
Follow this Question
Related Questions
Value between two states 2 Answers
Single Time Animation Play 1 Answer
SendMessage static parameters checking 0 Answers
Vector3 as Constant in Script 1 Answer
rigidbody2D.MovePosition() Can't Found 2 Answers