Cross-platform: PC, mobile, web, console Both 2D and 3D Scripting in C# Free but with limits Monthly subscription (more features) https://unity.com/ https://learn.unity.com/ UNITY The Game Engine
Powerful Free Used by many industries: Automotive and Transportation Brand Ads Film Gaming Gambling Learning and Training AR and VR Why UNITY ?
Project: Access and manage the assets in the project Scene: Interactive view of the world . Select and position all the objects Game: Represents your final published product Inspector: detailed information about the currently selected object. Hi erarchy : List of all objects UNITY Windows
Project Window
Scene Window
Game Window
Inspector Window
Hierarchy Window
Every object in the game is a GameObject (important) Components can be added into it to give it properties UNITY Basic: GameObject
Determines position, rotation, and scale All GameObjects have a Transform component Cannot be removed UNITY Basic: Transform
Helps identify GameObjects for scripting purposes UNITY Basic: Tags
Static: Inform that the object will not move. UNITY Basic: Static
Store GameObjects along with its properties and components Create instances A change in a prefab affects all its instances. Instance settings can be overridden. UNITY Basic: Prefabs
Light Define the colour and mood of the 3D environment. Different kinds of lights: Directional Point Spotlight Area
Camera Display the game world to player. At least one camera in a scene. Can be set to either Perspective or Orthographic projection.
Scripting Essential in all games. Unity uses C# as the main scripting language. Uses: Response to input Trigger events Create graphical effects Control physical behavior Implement custom AI system And many more
Scripting: Syntax Basic Syntax (Grammar): Keywords – words with special meanings Comments – for documentation purposes Variables / Attributes – act as containers to values Functions / Methods – a group of reusable code performing a task Operators – for logical/arithmetic operations Predefined values – values hardcoded into the script String – words that will appear as is when executed. *Syntax is case-sensitive. Meaning “ abc ” is NOT equal to “ABC”.
Scripting: Data Type Primitive data type: Defined by the programming language. Programmer-defined data type: Defined by the programmer Defined by tool such as Unity
Scripting: Variables A name given to a storage area used to store values of various data types. Syntax: data-type variable-name ; data-type variable-name = data-value ; data-type variable-name1, variable-name2 ; Example: int num = 1 ; There are rules when naming a variable: Cannot begin with numbers or special characters: int 1num ; Cannot use keywords: int int ; Cannot have empty spaces: int num one ;
Scripting: Array A collection or series of the same data type. The content of an array are called its elements. Array elements always begin with 0; Syntax: data-type [] array-name ; Example: int [] nums ;
Scripting: Class Encapsulation of data properties and data methods. Properties: describe the data the class will be holding. Methods: what operations can be performed on the data.
Scripting: Decision making Decision-making if, if…else, nested if switch Conditional operator: “? :”
Scripting: Loop Looping While, do…while For, foreach