Basic functions in unitscript

I have only the main question. I am trying to learn how to use functions with singlescript, and I found out that when you create a function using something like

function Example(text)
{
    print(text);
}

and then call it using

Example();

you can insert a string or number in parentheses on the last piece of code in parentheses, and it will go through and insert itself into a previously created function. In this case, it prints everything that I type in parentheses.

Now, my question is: if this works, then why are there no functions in which I pass two numbers, and ask them to add work? The code I'm trying to use looks like this:

Addition(4, 4);
function Addition(a, b)
{
    print(a+b);
}

When I try to accomplish this, Unity tells me

The + operator cannot be used on the left side of the Object type and the right side of the Object type.

Javascript 9 , script . , , . .

+5
2

, Unity :

Addition(4, 4);
function Addition(a:int, b:int)
{
    print(a+b);
}

, . , , JavaScript . .

, UnityScript. UnityScript - , , , Unity Javascript Javascript, .

UnityScript Javascript . bulletlist -, , (, ):

  • JavaScript
  • JavaScript var.
  • JavaScript .
  • JavaScript . , , var, .
  • Javascript .
  • JavaScript .
  • ($) UnityScript, JS.
  • UnityScript with.
  • Javascript Regular Expression Literals (RegExp regex).
  • JavaScript this , :
    • ( )
    • ,

, UnityScript. StackOverflow:

Unity JavaScript ECMAScript, JavaScript, . , Microsoft JScript, , .NET-. , Unity's , .

. .

+5

Unity JavaScript - 4 Number, .

, valueOf().

0

All Articles