Simple Problem with SendMessageUpwards

THis should be easy but somehow I’m not quite getting it…

I have a menu on the left side of my screen, and I want it to s=display different options at different times. So, here’s what I’m trying to do…

  • When the main map is set to the overall view, it should have one set of buttons, when “zoomed” it should show a different set. The script containing the buttons is attached to the main frame of the screen (mesh name = Main_Screen_Frame), and I was thinking a SendMessageUpwards should alternate between the two just fine right? (Seeing as the “zoomed” map is just a child of the main frame.)

BUT… when using this code:

function OnMouseDown () {
	SendMessageUpwards ("SectorView", Main_Screen_Frame, SendMessageOptions.RequireReceiver);
}

I get this error message:

BCE0005: Unknown Identifier: ‘Main_Screen_Frame’

Any one see what I’m doing wrong?

You’d need to have a variable called Main_Screen_Frame; apparently you don’t have one. (Although you should use lowercase to distinguish variables from methods and classes.) Having an object in the scene called “Main_Screen_Frame” isn’t related to the script at all; you need a reference to it, which would be stored in a variable. Although I’m not quite getting what you’re attempting, since you use SendMessageUpwards to send a value of some kind to a function on all scripts attached to the object and all of its parent objects.

–Eric

Sorry but that answer is really confusing to me - or does SendMessageUpwards work along completely different lines than BroadcastMessage, where I know variables aren’t needed?

What I’m trying to do is this (And let me see if I can explain more clearly):

  • I have a script on an object, said script is responsible for all the GUI controls on the screen.

  • I have clickable objects throughout the map that will bring up enlarged versions of that sector of the map.

  • Doing so should also change the GUI menu in one section of the screen (the script attached to the object mentioned above).

  • Those GUI’s will manipulate the map to reflect different criteria (i.e. military units, economic assets, etc etc) so there is a good amount of message-sending back and forth across 3 objects.

SendMessageUpwards and BroadcastMessage both work on GameObject hierarchies, not the entire scene. If you want to send a message to some other object in a different hierarchy, you need to get a reference to the other object.

–Eric

Both objects are in the same hierarchy.

Still absolutely puzzled by this

You have to define Main_Screen_Frame before you use it. That’s what the error message is telling you.

And that’s where I’m confused. I don’t know what “defining” it means in this context.

Then you should do some basic programming tutorials. Also - https://www.google.com/search?q=BCE0005%3A+Unknown+Identifier

In this context Main_Screen_Frame has no value.
If you would like to use Main_Screen_Frame, you have to tell the script what is this object, for example, if it is a camera
var Main_Screen_Frame:Camera;

if it is a game object
var Main_Screen_Frame:GameObject;

Like this, you can use the editor to drag an object in this value in Compoment Window or assign something with your script using a search.

Thanks. Not that it’s pertinent to my overall question, but any idea why this is necessary with SendMessageUpwards (and, I’m assuming, SendMessage as well), but not with BroadcastMessage?

This isn’t true. It’s not defined, which is not the same as not having a value.

It’s not necessary. Omitting it sends a default null value which is the same behavior as SendMessage and BroadcastMessage.