CS2335
Master 1.0.0
Master 1.0.0
  • Introduction
  • Introduction
    • Introduction
      • Game Design
    • Unity - Download
    • Visual Studio - IDE
    • Unity Manual, Scripting API
  • Unity Basics
    • Unity Editor Windows
    • Behavior Components
    • 2D Project, Scenes
      • Create 2D Sprite GameObject
      • Create UI-Text GameObject
    • MonoBehavior - Base-Class
    • Create a Custom C# Script
  • Game Coding Structures
    • Games Overview
    • Unity Engine - Event Functions
    • Finite State Machines
    • UML Class Diagram
  • Animation
    • Animator Controller
    • Animation Steps
      • Optional: Dead Animation
    • PlayerController.cs V0
  • Project 1 - Player
    • Player GameObject v1
      • C# Generics, Statics
    • Player GameObject - Jump
    • PlayerController.cs V2-Jump
    • PickUp PreFabs
      • Sorting Layers
    • PlayerController.cs V3-Collide
    • GameData Version1
    • GameData Version2
    • PlayerController V4-Score
  • Project 1 Details
    • Project1 GameObjects
    • PlayerStats Version1
      • UI-Canvas
    • Utility Class
    • Simple Spawner
    • MiniGameManager
      • Logic Diagrams
      • StartButton
      • ResultsPanel
  • Project1 Enhancements
    • PickUp - SelfDestruct
    • Spawn from List of Prefabs
  • Project 2 - StateManager
    • Project 2 - Learning Objectives
      • Inspiration
        • Branching Story Structures
        • Branching Structures
        • Hero's Journey
        • Visual Novel in Unity-Links
    • Project 2 - Starter Assets
    • State Machine Framework
    • StateManager - Singleton Design Pattern
    • Interface IStateBase
    • Create SceneXState.cs
    • OptionPanel Prefab
      • UI Images: Sprite Sheets
      • Button Image-Transitions
    • Project 2 - List of Steps
    • Project 2 - Starter Code
  • Project 2 -Dialogue
    • Hide_Show_Panel Script
    • Edit OptionPanel
    • Simple DialogPrefab
    • Conversation Entry
    • SimpleDialog.cs
    • ScriptableObjects
      • Scriptable Object Factory
    • Conversation Scriptable Objects
    • DialogManager_ConvList
      • DialogManager V2
      • Coroutines: Dynamic Text
      • DialogPrefab wImage
  • Overview: Branching Logic
    • DialogTrigger
    • Dictionary Data-Structure
      • Unity PlayerPrefs Dictionary
    • GameData Version3
    • Dictionary: choiceData
      • SaveChoice, ChoicePanel
        • choiceData - examples
          • Dictionary Value to Disable Options
    • Configure UI-Button Listeners
      • NPC Animation
      • NPC Activation
    • UI-Triggered Animations
    • Simple Inventory
    • EndState Conditions
    • Script ExecutionOrder
    • Custom UnityEvents
    • PlayerStats v2
      • ModifyPlayerData
      • BuyItem
    • Text Input
  • UI Components
    • Finding Game Objects
    • Game Objects: UI vs. 2D Sprite
    • UI Elements
      • Canvas: Screen-Space Render-Mode
      • UI-Buttons To Change Scene
  • Proj4: Inventory System
    • Inventory-System
      • GameData version4
      • Install and Configure
      • Diagrams, Resources
        • Item, Gem, Potion Classes
        • Inventory Class
      • InventoryDisplay, Slot UI
        • InventoryDisplay Class
        • Slot Class
        • Hazard Class
        • Layout Groups
      • Customization Steps
        • Configure Animation
        • AddItem Button
        • Concrete Class: Food
        • MiniGame Mods
          • PlayerController Mods
      • Code: InventorySystem
        • GameData, PickUp Mods
      • Resources: Data Structures
  • Custom Unity Events
    • Event Publishing Patterns
    • Custom Event Messaging
  • Proj4: Mini-Game
    • Simplified Mini-Game
      • PlayerController_v2 Mods
        • PlayerController_v2_final
      • MiniGameManager_v2
    • MiniGame-Overview-Proj4
    • LevelManager
      • LevelManager Logic Diagram
      • LevelManager FSM
      • LoadLevel, StartLevel Logic
      • Code Framework
    • Timer
  • Project 4 - Code Mods
    • Project 4 - Steps
    • Project 4 - Code
      • Code: Final Versions
        • PlayerController Mods
          • PlayerController_v2 Mods
        • GameData - Final
        • LevelManager
        • PlayerStats - Final
        • PickUp, Hazard, ScorePickUp
        • Spawner - Final
        • CameraFollow
        • ScreenFader
        • MiniGameState
        • Example: EndState
      • MiniGameWin Logic
  • Optional, Supplemental Content
    • Optional Content
      • Particle Systems
      • Adding Audio
      • Screen Fading and Reloading
      • ScriptableObjects
      • Disable Debug Logging
      • Events and Actions
      • Saving Data - Serialization
      • Parallax Scrolling
      • Change Sprites
    • XR - Extended Reality
  • Computing Concepts
    • Programming Patterns
      • State - FSM
      • Singleton Pattern
    • C# Language
      • Variables
      • Delegates
      • Dictionary
      • Enum
      • Encapsulation
        • C# Properties
        • Access Modifiers
      • Generics < T >
      • Inheritance
      • Interface
      • List< T >
      • Polymorphism
      • Queue< T >
      • Switch-Case
      • Foreach
      • Static
      • Ternary Operator: ?
      • this
    • Diagrams
      • State Machine Framework
      • UML Class Diagrams
      • Level Manager Logic Diagram
      • Flow-Chart: NumberGame
      • FSM: NumberGame
    • Tools
    • Glossary
    • References and Resources
    • Random Thoughts
Powered by GitBook
On this page

Was this helpful?

  1. Unity Basics

Behavior Components

Component Oriented Architecture

Unity uses a Component Oriented Architecture which is a type of Object Oriented programming designed to reduce complexity and enhance modularity compared to traditional Inheritance structure for creating game entities. Components enable gameObject Behavior The idea is that most of the custom code that you'll write for Unity is designed to create a specific custom behavior for a gameObject. This means that it's easy to create slightly modified versions of a type of gameObject by simply using a different type of behavior component, such that an entire new child-class definition is not required. The most basic type of Unity scripting is creating custom gameObject behaviors, where most gameObjects have many different components that may interact with each other to control the gameObject's behavior.

Definition: A Unity GameObject is essentially an empty container that has a 3D world position specified in its Transform component. Multiple standard or custom components can be added to the GameObject to give it customized behaviors.

Behavior Components: Important Details:

  • All Unity Components must inherit from the MonoBehaviour base-class. When you create a C# script, MonoBehaviour is specified as the base-class by default. Any Component must have MonoBehaviour as it's base-class.

  • Component class variables defined within a component's class definition define attributes for the component, some of these can be configured to be editable in the inspector panel.

  • The Inspector panel displays and allows modification of components on a gameObject that is currently selected in the Hierarchy Panel.

Default, Empty GameObject - Transform Component

  • All gameObjects must have a Transform component which specifies x, y, z coordinates of it's position in the scene's world-space.

  • The default empty gameObject only has a Transform component, all other components must be manually added.

  • The Transform component of a Child gameObject is defined relative to its' Parent gameObject's Transform component. Any change to the Transform Component of a Parent gameObject will result in corresponding change to the Child gameObject.

  • UI-GameObjects (user interface) have a Rect-Transform component which provides the ability to define width, height, anchor-points relative to the default UI canvas or the parent UI-gameObject for a child UI-gameObject.

Pre-Configured, Prefab Components

  • Unity provides pre-configured GameObjects: The GameObject menu allows for creation of many types of standard, pre-configured gameObjects, in many cases, additional custom components are than added to the pre-configured gameObject: example 2D-Sprite, UI-Text

  • Prefab GameObjects:

The idea is that any type of GameObject can be created by adding custom behaviors added to it.

Adding Components to GameObjects: Unity provides many standard components but the ease of creating custom components to create custom behavior allows for a modular game design process. Components are added to a gameObject using the Drop-down menu at the bottom of the Inspector Panel

Example: an apple gameObject and a balloon gameObject might both have been created using the standard 2D-sprite gameObject. Their behaviors may differ due to each having the same type of physics RigidBody2D component with modified gravity attribute values, such that the apple falls and the balloon rises. For enhanced behavior, the apple might have a custom component that allows it to be collected and used to extend a player's health, while the balloon may have an Animator component that displays a pop animation when the balloon hits a time or height constraint.

PreviousUnity Editor WindowsNext2D Project, Scenes

Last updated 4 years ago

Was this helpful?