How to pass function as parameter to function?

I need to set up a custom input manager (which isn’t truly custom, it just builds on the standard Input class) and to do so I need to be able to register callback functions (assuming I’m using that term correctly).

Using UnityScript, how can I pass a function as a parameter to another function?

Hi. Hope the following is what you’re after. I don’t do js/us so had to learn a new language :wink:

#pragma strict

function Update () {
  // Do testing
  DoTest(FunctionUsedAsParameter);
}

// Returns dumb test string
function FunctionUsedAsParameter()
{
  var message = "Test me for this test message!";
  return message;
}

// Test function
function DoTest(funcAlias: Function)
{
  // get test string
  var test = funcAlias();
  Debug.Log(test);
}

Important note: The use of capital F in Function (funcAlias: Function) is essential to make this work