Beginner's Guide to C# and Unity
PART 1: Getting Started
- Download Unity Hub from https://unity.com/download
- Install Unity Editor (LTS version recommended)
- Create a New Project using the 2D or 3D Core Template
PART 2: Introduction to C# in Unity
- Variables - Store data (e.g., int score = 0;)
- Methods - Perform actions (e.g., void Jump() { })
- Classes - Define behaviors (Unity scripts are classes)
- Loops - Repeat actions (for, while)
- Conditionals - Make decisions (if, else if, else)
- Events & Input - Handle input with Input.GetKey, Input.GetAxis
PART 3: Unity Scripting Structure
- Start() - Runs once at the beginning
- Update() - Runs every frame
Example:
void Update() {
float move = Input.GetAxis("Horizontal");
transform.Translate(move * Time.deltaTime * 5f, 0, 0);
}
PART 4: Working with GameObjects
- SetActive() - Activate or deactivate objects
- Instantiate() - Create objects at runtime
- Destroy() - Remove objects
PART 5: Unity Editor & Components
- Rigidbody - Apply physics
- GetComponent - Access other components
- OnTriggerEnter - Detect collisions with triggers
PART 6: UI Elements & Input
- Use UnityEngine.UI and attach Text components
- Update UI with scoreText.text = "Score: " + score;
PART 7: Project Ideas for Practice
- Endless Runner - Movement, spawning, collision
- Platformer - Physics, jumping, UI
- Puzzle Game - Logic, object interaction
- Top-Down Shooter - Input, bullets, enemies
PART 8: Learning Resources
- Unity Manual - https://docs.unity3d.com/Manual/index.html
- Unity Scripting API - https://docs.unity3d.com/ScriptReference/
- Microsoft C# Tutorials - https://learn.microsoft.com/en-us/dotnet/csharp/
- Brackeys (YouTube)
- Unity Learn - https://learn.unity.com
- Udemy - Complete C# Unity Game Developer by GameDev.tv