Is this C# correct in Unityscript?

Hi all,

is this C# code.

public bool isValid
    {
        get
        {
            return _isValid;
        }
    }

This in Unityscript.

function isValid() : boolean
{
  return _isValid;
}

And would all Public bool, int, and float statements that are set the same as the above C# code be the same as what i have done in the unityscript?

Thanks.

That's a C# property. You created a normal function to read it. Properties can also be declared in UnityScript but you will need to explicitly declare the containing class.

See this question.

edit

The difference is in your case you have to call the isValid function manually:

if (myScriptInstance.isValid())

Properties looks like normal variables and can be used like variables but behind the scenes it calls the get / set function

if (myScriptInstance.isValid)

The big advantage is that you can do some extra stuff when someone, somewhere assigns a value to this "variable". In your case the property is read-only since it doesn't have a set function