#4 | PROPERTIES & GET/SET METHODS 🎮 | Unity For Beginners | Unity Tutorial

preview_player
Показать описание
Hi everyone! 🙂 Today I will show you what Properties are and how to use them when it comes to C#.

➤ TIMESTAMPS

00:00:00 - Introduction
00:01:25 - How to create Properties
00:03:26 - Why are Properties better to use?
00:06:00 - Creating multiple properties using one field
00:09:18 - Auto-properties

➤ GET ACCESS TO MY LESSON MATERIAL HERE!

First of all, thank you for all the support you have given me!

I am really glad to have such an awesome community on my channel. It motivates me to continue creating and uploading content! So thank you!

I am now using Patreon and YouTube Memberships to share improved and updated lesson material, and for a small fee you can access all the material either from my memberships or Patreon, depending on your preference. I have worked hard, and done my best to help you understand what I teach.

I hope you will find it helpful :)

Рекомендации по теме
Комментарии
Автор

Hi everyone! Yes I had to re-create this video since there was a mistake in my example, which might have confused a lot of people since I say one thing, but show another hehe. Also, a friendly commenter named Matthias made me aware that I had misunderstood how "auto-properties" functioned internally, so here is a corrected version since I don't wish for my lessons to be misleading. 😊 So thank you Matthias.

Dani_Krossing
Автор

These are actually great videos that help me understand what I’m doing instead of just doing it

rrydaa
Автор

This is the BEST explanation of 'Properties' I have ever come across.

Jamie
Автор

god bless you elon musk i just wanted to let you know that your c# videos help me substantially and you are signifcantly better then the professor teaching the course i am currently in

aw_shucks
Автор

Thank you so much for explaining clearly and succinctly how and why to do this! So many tutorials tell you how but never explain exactly why and when to use something.

lAcedUpLiss
Автор

It is rare in game development to see a tutorial that actually explains what is being done and why it is being done instead of just writing billions of lines of code in a second.

KillAllCommies
Автор

In Visual Studio you can type "prop" and hit tab twice and it will fill out the property for you. You can then hit tab to scroll through the name and datatype of the property. If you do "propg" instead it will create a property with a private setter which is my preference for creating immutable data structures. This functionality is called a "snippet", you can make your own too.

joebrady
Автор

you teach a lot better than those paid teachers on udemy, you saved my day !

VictorQiu-olms
Автор

You can type out "prop" and hit tab to use intellisense to create an auto property quickly. Default behavior creates a public integer property.

shahroznaeem
Автор

I think I've found the perfect tutorial. Thank you very much and do not stop doing it, please.

Piringochas
Автор

Thanks a lot sir, we need more ppl like you. i like ur way to explain every step

McPatoo
Автор

Thank u so much for everything, I am just starting up and follow all ur step, and it was really beginner friendly! Absolutely splendid!

jaxkk
Автор

Dude, thanks to you, now I feel like I can make any website, I’m goin go to new languages already, thank you very much sr

stepbro_davo
Автор

Earned a new subscriber, master. Looking farward to gain more knowledge

SaitamaMixed
Автор

Just started watching this series, very good you tech me ehat to do instead of just me copying code.

FoxeyWind
Автор

The quick code change at 9:19 made me think I was going crazy for a second.

brisinger
Автор

The C# syntax for get and set methods (properties) is something I will have to get used to. I'm used to the way that Java creates get and set methods.

Soulsphere
Автор

Quick question: why was the variable in the Field called _playerhealth = 100 set to private, but the property Playerhealth set to public?

ikonhero
Автор

By the way, it is possible to expose properties to the Unity inspector by adding the tag [field: SerializeField] above the property.

lamywater
Автор

Oh man i was so confused but it was something i was doing in my code already, in a way.
I did have getters/setters but i implemented them through seperate functions. Guess i can replace those with properties now that i know its pretty much same thing, except likely more clear since its all in one place. Thanks a lot!

Bobster