how to make function parameters don't need to declare (custom parameters)??

how to make function parameters don’t need to declare (custom parameters)??


I can to do it like this

GUI.Label(position : Rect, text : String)

or I add more parameter like (style : GUIStyle)

GUI.Label(position : Rect, text : String, style : GUIStyle)

I mean

function MoveToEnd (speed : float,typeMove : String)

I want (typeMove : String) optional

thx …

You can’t do it in JavaScript. You can in C# and there are a couple of methods.

  • A string is converted into a GUIStyle because an implicit cast operator has been defined for it, that’s how you can have one parameter appearing to take two different types of value.

  • A parameter can be optional if you define it with a default value, such parameters must come last in the list.

You are better off having multiple methods in JavaScript which each have a different signature corresponding your desired parameters.