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)