- Scripts as Behavior Components
- Link: scripts-as-behaviour-components (3:27)
- Notes:
GetKeyDown(KeyCode.[Key on keyboard]) is how you make keys operate function in code with an if statement.
Drag and drop C# scripts to add to object.
“Add component” can create and add a C# script at the same time.
- Variables and Functions
- Link: variables-and-functions (5:52)
- Notes:
int = integer
int myInt = 5; means I want the integer 5.
Maintains value until assigned a new one.
Void doesn’t return values.
parameterName can put in parameters to what integer can appear.
Ret = return a number
Debug.log is console window
- Conventions and Syntax
- Link: conventions-and-syntax (4:10)
- Notes:
Syntax: structure of language
. Separates things that are sub of each other, think of country.city
; terminates, so use at end except for }
Indent to organize
//this is a normal one line comment
/* this is a
*two line comment
- C# vs JS syntax
- Link: c-sharp-vs-javascript-syntax (1:54)
- Notes:
Java uses less lines, c# more specific
Default is different, c# is private, java is public
- IF Statements
- Link: if-statements (1:27)
- Notes:
If chooses one or another depending on certain things that can happen
Else is what happens if it is false
- Loops
- Link: loops (5:33)
- Notes:
While happens until parameter is false
Do while is at end while while in at start, so do while always happens once.
Do while has semicolon at end
for does certain loops for certain parameters in increments
For each loops through items of an array until there are no more items
- Classes
- Link: classes (6:00)
- Example scripting and objects
- Notes:
Classes are where functions happen
Organize different functions into different classes for organization
Constructor gives default values for variables and it’s end syntax is ()
() is for parameters
Parameters are for new objects