Unity 3D Programming Flashcards
From which menu can you create a new C# script?
Assets
Match the type to the expression. 1. float 2. float or int 3. int 4. other A. 1 B. int someInt; C. “Some text” D. 1.0f
1D, 2A, 3B, 4C
What type is someVariable? float someVariable = 2;
float
What is the result type of the following operation? 2 + 2
int
What is the type of someResult ? float someFloat = 3; int someInt = 3; ??? someResult = someFloat + someInt;
float
Which is the correct suffix for floating point numbers?
f
Why would you choose to wrap some functionality into a method?
To deal with concepts at a higher level.
What is the return type of this function declaration? int DoSomething (string aValue) { }
int
What types of variable does this take? float AnotherMethod(string foo, int bar) { }
string and int
What type does this method return? [omitted] SomeMethod () { return 2.0f + 1.0f; }
float
What in the following would cause an error in Visual Studio? 1. float Square (float numberToSquare) { 2.float square = numberToSquare * numberToSquare * numberToSquare; 3. }
Nothing returned from the method.
What is the correct way to create a 3D vector?
new Vector3 (1.0f, 1.0f, 1.0f)
Which of the following is a valid operation on vectors (assume variables a and b contain Vector3)?
a.magnitude
In the following lines of code, why do we use a dot? Vector3 a = new Vector3(1, 2, 3);
float myX = a.x;
To access the contents x of the a variable
What data is a Vector3 made up of?
3 floats