- Home /
How do I send a message to every entry in a dictionary?
I'm working on an RTS and the resource item keeps a dictionary of every gameobject currently harvesting it. How can I use SendMessage on the contents? Or is there some better way of doing this that I'm missing?
Answer by fafase · May 29, 2014 at 06:53 AM
If you are sending the messgae to a particular game object you know, you can use a GetComponent on it and use a method like below:
void ModifyDictionary(Type value)
{
foreach(KeyValuePair<Type, Type> kvp in dict)
{
kvp.Value = value;
}
}
Thanks! I'd seen the use of $$anonymous$$eyValuePair<> in foreach loops before but it never quite registered until now.
Your answer
Follow this Question
Related Questions
Distribute terrain in zones 3 Answers
Multiple Cars not working 1 Answer
An OS design issue: File types associated with their appropriate programs 1 Answer
NGUI Health SendMessage Has No Receiver 1 Answer
Storing Items in a Building Blueprint 0 Answers