Static vs Instances | Unity C# Basics Part 4




Published: 26 Apr 2022

Learn about what "instance"s are, what's the difference between those and "static", and a common design pattern that uses both of these! If you've been following along in the series, you've already used both instances and static properties, maybe without knowing it! Today you will learn about what each one is and when you should use static or an instance. We'll also review the limitations of each type to deepen your understanding!


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 video series you need to start your programming journey!


๐Ÿ‘จโ€๐Ÿ’ป Unusually, this video does NOT have a project associated with it. For reference, you can view the project from the last video on GitHub: https://github.com/llamacademy/unity-csharp-basics-3


Full Series Playlist Here: https://www.youtube.com/watch?v=SXaa61JWLDw&list=PLllNmP7eq6TTjwoyfRYAAFOH1sMHVgI1r


โšซ Part 1 - Writing your first script - https://youtu.be/SXaa61JWLDw

โšซ Part 2 - Loops and Arrays - https://youtu.be/MB6B9nHSrps

โšซ Part 3 - Unity Component Lifecycle - https://youtu.be/TD3yoFg3GVI

โšซ Part 4 - Static vs Instances - https://youtu.be/JRRlAzBh-6U

โšซ Part 5 - Delegates - https://youtu.be/1N6k7Hj_JKc

โšซ Part 6 - Inheritance & Interfaces - https://youtu.be/siRvSZzrhRU

โšซ Part 7 - Compositional Relationships - https://youtu.be/khIweJfnyW4



๐Ÿ“๐Ÿ“๐Ÿ“YOUR HOMEWORK!๐Ÿ“๐Ÿ“๐Ÿ“


Create a static function that will create a prefab at a given location.

Bonus: Make it a singleton class with a local / instance function instead of a static function!


Add a comment below with a video showing your code and the end result.


๐Ÿท๏ธSave 25% on the ultimate C# IDE: JetBrains Rider with code LLAMACADEMY: https://www.jetbrains.com/store/?section=personal&billing=yearly


๐Ÿ“š Here are the resources I mentioned and/or brought up during the video ๐Ÿ“š

โšซ "this": https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/this?msclkid=df5ad20dbbe311ec97ddfab7d4a4fe95

โšซ "static": https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/static

โšซ Static classes: https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/static-classes-and-static-class-members

โšซ Screen: https://docs.unity3d.com/ScriptReference/Screen.html

โšซ Singleton: https://en.wikipedia.org/wiki/Singleton_pattern


๐Ÿงก Believe in LlamAcademy's mission and have received value from the videos? Here's how you can show your support:

๐ŸŒŸ Patreon: https://www.patreon.com/llamacademy

๐ŸŒŸ YouTube Member: https://www.youtube.com/channel/UCnWm6pMD38R1E2vCAByGb6w/join or click the Join button on any video

๐Ÿ“š Take my Unity ShaderGraph Course:

https://www.gamedev.tv/p/unity-shader-graph?affcode=45216_kuvg0bp7

๐Ÿ‘• Get yourself some LlamAcademy merch: https://llamacademy.myspreadshop.com/

๐Ÿ’ธ Use my Affiliate Link for Humble Bundles https://humblebundleinc.sjv.io/9g4ak4

๐Ÿ’ธ Publisher Sale! 50% OFF an entire publisher's Assets! Publisher changes weekly! https://assetstore.unity.com/publisher-sale?aid=1101l9QvC (affiliate)

๐Ÿ’ธ Save up to 50% on NEW Assets: https://assetstore.unity.com/?new_sale=true&orderBy=1&aid=1101l9QvC (affiliate)


Some links may be affiliate links, which at no additional cost to you, gives me a small portion of the purchase.


Connect on Social Media

Some links may be affiliate links, which at no additional cost to you, gives LlamAcademy a small portion of the purchase.