- Home /
Message not being recieved
I have a gameobject, and two images: the inventory, the inventory slot, and the slot icon image. The inventory sends a message to the slot every update:
item1 = inv[0];
Slot1.SendMessage ("recieveContentData", item1);
item2 = inv[1];
Slot2.SendMessage ("recieveContentData", item2);
item3 = inv[2];
Slot3.SendMessage ("recieveContentData", item3);
item4 = inv[3];
Slot4.SendMessage ("recieveContentData", item4);
The slot receives this message:
public void receiveContentData(Item newContents)
{
contents = newContents;
}
And then, every update, tells the slot icon to change it's image to that of the item, contents.
if (contents != null)
{
itemImage.enabled = true;
itemImage.sprite = contents.itemsprite;
}
else
{
itemImage.sprite = null;
itemImage.enabled = false;
}
}
The problem is, when I run this script, apparently there is no receiver to this message;
Even though I assigned all of the Slot variables to gameobjects with the slot script attached, and all of the slots have a Slot icon image as children. Here is the exact error message:
SendMessage recieveContentData has no receiver!
UnityEngine.GameObject:SendMessage(String, Object)
Answer by c00pala · Oct 16, 2014 at 12:29 AM
Check the spelling of Receiver - The I and E are different in the send message and the function - assuming the code has been copy/pasted?
Aw, crap. I messed up big there. Sorry for wasting your time. XD
No issues at all, mate. At least it's an easy fix for ya. =)