Search Unity

Tutorial - Compositional Relationships - You've Already Been Using Them | Unity C# Basics 7

Discussion in 'Community Learning & Teaching' started by ChrisKurhan, Sep 6, 2022.

  1. ChrisKurhan

    ChrisKurhan

    Joined:
    Dec 28, 2015
    Posts:
    268


    Hey all! Happy #TutorialTuesday!

    A lot of people copy/paste tutorial code without understanding what's going on, so to help with that, I started a Unity-focused C# Basics series aimed at absolute beginners. Here's part 6 where I teach about Inheritance (you've been using it this whole time!) and Interfaces!

    If you've been using Unity for a while, or are just getting started with Unity and decided it's time for you to start learning how to write code - this is the series for you! In most of my videos I expect you already know the fundamentals of writing code, but that's unfair to many of you who are just starting on your coding journey. That ends up with a lot of copy/pasting without understanding. This is a series I've started dedicated to teaching absolute beginner coders how to write C#, focused on Unity.

    In part 7 of the Unity C# Basics you'll learn about what Composition is, how to use it (you already are using it!), and how it relates to what we learned in part 6 with Inheritance and Interfaces.
    Composition is a powerful design pattern to apply that allows us to delegate responsibility of specific tasks and variables to other classes. This allows us to keep our code "clean" and focused on the area of responsibility of that particular class.

    Don't forget to complete your homework assignment to deepen your understanding of these concepts!
    Since this is the 7th part of an ongoing series, if you are an absolute beginner, start at part 1! Each part builds on the previous one as we learn how to use C# in a Unity context by practical hands on example.

    Unusually, this video does not have an associated GitHub repository, but it does reference the code done in part 6.

    Full Series Playlist Here
    • Part 1 - Writing your first script
    • Part 2 - Loops and Arrays
    • Part 3 - Unity Component Lifecycle
    • Part 4 - Static vs Instances
    • Part 5 - Delegates
    • Part 6 - Inheritance & Interfaces
    • Part 7 - Composition
     
    pm007 likes this.