Triggering events

Hi everybody,

I have objects of interest in my scene. I implemented the OnMouseUp() function in a script so that each time I click on them, they trigger some actions. Now, I want to do the same with buttons. Is there any way to tell my buttons to call the OnMouseUp() function of specific script attached to specific objects? Is there any better solution to do this?

regards.
K.

yeah,

GameObject.Find("MyUniqueGameObject").GetComponent("SomeComponent").OnMouseUp();

There are also other versions of Find in the class index of the scripting manual.

There is also the option to access the GameObject directly using a slightly modified code from above:

javascript

//  declare your game object (you must drag it into this slot in the properties window)
var ObjectWithTheScript : GameObject;
...
...
ObjectWithTheScript.GetComponent("NameOfTheScriptAttached").OnMouseUp();

This has the benefit of accessing the script directly rather than searching for it every time it’s called.

I tried this but it does not work. I must precise that I use C#. Is there any limitations?

[Edit] I should have think about it before posted…
In C#:

MyScriptClass script = (MyScriptClass)myObject.GetComponent("MyScriptClass");
script.OnMouseUp();

Thanks a lot for your help!
Regards.