Function in main script I want access to it from all scripts

I have my own debug function in my main script that I want to access from all other scripts…It’s a simple debug function that I call debugU which outputs to Debug.Log and to the webpage I’m working on so I can view errors while I’m using the player.

On the main script I can call debugU anytime I want because it’s in the script.
But in another script it doesn’t know the function.

I know I could write something long like
GameObject.Find(“mainscript”).DebugU() but that would defeat the purpose of making it simple to write.

Is there a shortcut?

Thanks.

Dan

Make it a static function.

–Eric

static function myfunction(){}

that didn’t work.
How do you make a static function?

Thanks,

Dan

Try this:

var scriptObject = GameObject.Find("NameOfObjectWithScript");
var debugScript = scriptObject.GetComponent("debugU");
debugScript.functionName();