Unityscript - what is this declaration?

I come from other programming languages ​​and I am new to Unityscript. I am trying to understand what Unityscript code does.

I found this line

var guiTouchPos : Vector2 = touch.position - guiTouchOffset;

What is this declaration? What does this line do? It would not be easy to write

var guiTouchPos = touch.position - guiTouchOffset;

since I don't see Vector2 being used anywhere in the code?

Is this a string that assigns subtraction to both variables?

thank.

+3
source share
3 answers

This is not JavaScript, it is ActionScript 3 or UnityScript . :indicates type declaration.

+11
source

This syntax is not valid in JavaScript, so it is written that may not work.

UPDATE

ActionScript, (Vector2 ) ; , -, JavaScript- Unity, , Chuck answer, -, . Unity "JavaScript" , - JavaScript.

+5

Source: https://habr.com/ru/post/1771699/


All Articles