Variables and Functions

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

Variables

Boxes that contain information. you need a different variable for each piece of information

Debug.log format

Debug.log() a variable goes inside the set of parentheses. example: Debug.log(uhr)

What is Void start

an example of function that doesn't return anything. its type is void

where do the "inner workings" of a function begin

between { and }

how do we start our variable definiton

by saying what type of box we'd like

variable formula

declaration = Initialisation

what do variables and parameters go in

parentheses

int

integer, or a whole number.

what happens to a variable given a value

it will keep the value until you give it a new one. Example: Using Unity Engine; Using System.Collections; public class: VariablesandFunctions : MonoBehaviour { Int uhr = 5; Void Start (){ Debug.log(uhr * 5); } } this line of code will multiply uhr by 5, and the console will read the value as 25 (5*5)

Name of the variable

just a name to reference it by. can literally be anything, but it can't start with a number or symbol

return

literally returns whatever goes after it. ex: Int thing(int num)

what does a function do

take the boxes that we have storing information and give us boxes back, or 'return' as it is known

what do the curly braces open and close around

the actions that are in our function

what goes inside the parentheses of a function

the data that is sent to parameters

declaration

the first part of the variable; consists of the type (In blue), and the name of the variable (case sensitive)

initialisation

the second part of the variable, where information is stored. also called the value

type

the type of variable. Ex: Integer Int

function format

type FunctionName(type parameter names);

start function format

void Start { }

what can we do with making our own functions

we can give it a specific type of box to return

what can we do with Debug.log

we can output anything to the console (including variables)

what happens when you make a new script

we're given start and update functions

Value

what the variable equals. for example, Int uhr = 5. the variable would equal five

when is the function Start called

when an object the script is attached to enters a scene

how do we end any line of code

with a semi colon. Ex: Debug.log();

what happens when you log the value of the variable, save the script, and attach it to an object

you can see it in the console in unity, and you can also see the value when you hit the play button


Kaugnay na mga set ng pag-aaral

Case study of a contrasting coastline- The Sundarbans Bangladesh

View Set

How many days are there in a week? 一個星期有幾天?

View Set

Stats Midterm Practice Exam Questions

View Set

Ch. 16: Population, Urbanization, and Environment

View Set

Quiz Chapter 9 Service Processes

View Set