I am setting up a selection system like one you might see in an RTS game. Having said that, I have a slection script to be placed on every selectable prefab/gameobject. Inside this script i have a function SetSelect().
What I am trying to do is raycast to the object, then call that object's SetSelect function.
It may have to do with when or how you are getting your GameObject or when or where you are calling the functions or even just how you're testing whether the function is being called. Without more information like a more complete section of script, it is impossible to guess.
I just tested this setup and it works:
CameraPicker.js
var hit : RaycastHit;
function Update() {
if(Input.GetMouseButtonUp(0) &&
Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition),hit)) {
hit.collider.gameObject.SendMessage("Test");
}
}
Selectable.js
function Test () {
Debug.Log(gameObject.name);
}
If this does not address your issue, please include more information as it is likely some other part of your script that is not behaving as you expect.