Unity3D: default parameters in C# script

Posted by Heisenbug on Game Development See other posts from Game Development or by Heisenbug
Published on 2012-09-08T12:42:35Z Indexed on 2012/09/08 15:50 UTC
Read the original article Hit count: 337

Filed under:
|
|

Accordingly to this thread, it seems that default parameters aren't supported by C# script in Unity3D environment.

Declaring an optional parameter in a C# scirpt makes Mono Ide complaint about it:

void Foo(int first, int second = 10) // this line is marked as wrong inside Mono IDE

Anyway if I ignore the error message of Mono and run the script in Unity, it works without notify any error inside Unity Console.

Could anyone clarify a little bit this issue? Particularly:

  • Are default parameters allowed inside C# scripts?
  • If yes, are they supported by all platforms?
  • Why Mono complains about them if the actually works?

© Game Development or respective owner

Related posts about c#

Related posts about unity