Static vs Instances | Unity C# Basics Part 4 #Shorts




Published: 28 Apr 2022

Full Tutorial: https://youtu.be/JRRlAzBh-6U


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


Want the previous episodes?

⚫ Part 1 - https://youtu.be/SXaa61JWLDw

⚫ Part 2 - https://youtu.be/MB6B9nHSrps

⚫ Part 3 - https://youtu.be/TD3yoFg3GVI

⚫ Part 4 - You are here!



📝📝📝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.


📚 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? Consider becoming a Patreon supporter: https://www.patreon.com/llamacademy

----

Most tutorials come from knowledge gained making https://survival.llama.software Llama Survival - a top-down zombie survival shooter for Android and iOS.

I also have some Unity Assets (affiliate link): https://assetstore.unity.com/publishers/22409?_aid=1101l9QvC


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.