0% found this document useful (0 votes)
12 views3 pages

C# With Unity

The document provides an overview of fundamental programming concepts in Unity, including variables, data types, operators, and control structures like if/else and switch statements. It also covers essential Unity-specific elements such as GameObjects, components, and methods for handling input, physics, and scene management. Additionally, it introduces basic UI elements and audio management within the Unity environment.

Uploaded by

katmoviehdfarhan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views3 pages

C# With Unity

The document provides an overview of fundamental programming concepts in Unity, including variables, data types, operators, and control structures like if/else and switch statements. It also covers essential Unity-specific elements such as GameObjects, components, and methods for handling input, physics, and scene management. Additionally, it introduces basic UI elements and audio management within the Unity environment.

Uploaded by

katmoviehdfarhan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

Beginner Level 🎯

1. Variables – Store values for later use.

int score = 10;


string playerName = "Farhan";
bool isAlive = true;

(Use to store numbers, text, true/false)

2. Data Types – Kinds of values variables hold.

int → whole numbers

float → decimal numbers

string → text

bool → true/false

3. Operators – Do math or comparisons.

int sum = 5 + 3; // 8
bool check = (score > 5); // true

4. If / Else – Run code based on conditions.

if(score > 10) { [Link]("You win!"); }


else { [Link]("Try again"); }

5. Switch – Multiple conditions cleaner than many ifs.

switch(level) {
case 1: [Link]("Easy"); break;
case 2: [Link]("Medium"); break;
default: [Link]("Hard"); break;
}

6. Loops (for, while, foreach) – Repeat actions.

for(int i=0; i<5; i++) { [Link](i); }

7. Methods (Functions) – Group code for reuse.

void SayHello() { [Link]("Hello!"); }


SayHello();

8. Classes & Objects – Blueprints for objects.


class Player { public int health = 100; }
Player p = new Player();

9. Unity Editor Basics – Learn Scene, Game, Hierarchy, Inspector, Project. (No
code)

10. GameObject – Any object in the scene.

GameObject obj = new GameObject("Enemy");

11. Component – Scripts or physics on objects. (Add via Inspector or


AddComponent<T>())

12. MonoBehaviour – Base class for Unity scripts. (Needed for Unity-specific
functions like Start/Update)

13. Start() & Update() – Start runs once, Update runs every frame.

void Start() { [Link]("Game Started"); }


void Update() { [Link]("Every Frame"); }

14. Transform – Position, rotation, scale.

[Link] = new Vector3(0, 1, 0);

15. Input – Get player input.

if([Link]([Link])) { [Link]("Jump"); }

16. Awake() & OnEnable() – Awake runs before Start, OnEnable runs when object is
activated.

17. FixedUpdate() – Physics updates. (Runs at fixed time steps)

18. Rigidbody – Adds physics.

Rigidbody rb = GetComponent<Rigidbody>();
[Link]([Link] * 5);

19. Colliders – Detect collisions. (BoxCollider, SphereCollider, etc.)

20. Triggers – Detect overlaps.

void OnTriggerEnter(Collider other) { [Link]("Touched"); }

21. Prefabs – Save reusable object templates. (Drag object to Project folder)
22. Instantiate / Destroy – Create or remove objects.

Instantiate(prefab, position, rotation);


Destroy(gameObject);

23. Tags & Layers – Label and group objects. (Use for collision filters)

24. Unity UI Basics – Canvas, Text, Buttons. (No code yet)

25. Scene Management – Switch scenes.

using [Link];
[Link]("Level2");

26. AudioSource & AudioClip – Play sounds.

[Link](clip);

27. [Link] – Smooth movement regardless of frame rate.

[Link]([Link] * speed * [Link]);

28. [Link] – Get random number.

int rand = [Link](1, 10);

You might also like