Call Function via property in UnityScript

I use UnityScript as a last resort.
But, I’d like to call Function via property.

I wrote like this

    protected var _callbackFunction : Function;
    private function get CallbackFunction() : Function
    {
        return var _callbackFunction;
    }
    public function set CallbackFunction( value:Function )
    {
        var _callbackFunction = value;
    }

But, I can’t call the CallbackFunction get property

I can call below, but it is not via property.

_callbackFunction();

I can’t call like them…

// doesn't work!!
CallbackFunction;
// doesn't work!!
CallbackFunction();

Any idea?

You don’t use var when assigning values to variables. Only when declaring them. “return var _callbackFunction” is not something that would even compile, and “var _callbackFunction = value” is creating a new variable, which you do not want.

–Eric

Hi Eric5h5

Thank you for replying.
I’m sorry. I modified my code, cause of, I protected sensitive information. so, mismodified. But, in fact I didn’t write “var”.

However, it doesn’t work

    protected var _callbackFunction : Function;

    private function get CallbackFunction() : Function {

        return var _callbackFunction;

    }

    public function set CallbackFunction (value:Function) {

        _callbackFunction = value;

    }

You still have “var” in there where it shouldn’t be.

–Eric

wow// i mistook again

    protected var _callbackFunction : Function;
    private function get CallbackFunction() : Function {
        return _callbackFunction;
    }
    public function set CallbackFunction (value:Function) {
        _callbackFunction = value;

    }

You say you use UnityScript as a last ressort, are you implying you are currently using C# ? Because you could take a look then at the Action type.

Thank you I try