Quick #UnityTip - Serialize your Properties! - WHAT?

Quick #UnityTip - Serialize your Properties! - WHAT?

Jason Weimann

2 года назад

14,324 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@supertenchoo4271
@supertenchoo4271 - 03.05.2022 20:37

great tips

Ответить
@chaosthelegend6338
@chaosthelegend6338 - 03.05.2022 20:40

you can do that! wow! Great tip

Ответить
@lotussy7698
@lotussy7698 - 03.05.2022 20:50

Unfortunately, the split into 3 Lines for the Short format is unreadable, since most of the screen is covered by the overlay :-p

Ответить
@marche4ever
@marche4ever - 03.05.2022 20:53

One thing to look out for is when you need to rename the variable, typically you would use [FormerlySerializedAs] on the backing field to keep its' inspector values (your IDE might do this automatically), but when the backing field is implicit, it's harder to rename it, since you need to know the system generated name for it (IDE doesn't automate this process).

Ответить
@MasterofGalaxies4628
@MasterofGalaxies4628 - 03.05.2022 20:59

I learned this some time ago and I do think it's kinda cool, but I've never really used it because the FormerlySerializedAs attribute doesn't work with this format. So I still go with the explicit field and the get-only property wrapper.

Ответить
@bob27111
@bob27111 - 03.05.2022 21:04

man i CAN"T see the same effect, there are links to other vids

Ответить
@goldone01
@goldone01 - 03.05.2022 21:04

This is amazing - thanks very much for the tip!

Ответить
@fejza
@fejza - 03.05.2022 21:21

Whaaaaaaaaaat since when does this exist?

Ответить
@zentec010
@zentec010 - 03.05.2022 21:22

20sec in the vid gets covered so no idea what you did.

Ответить
@kasquez
@kasquez - 03.05.2022 21:27

Please make normal videos.

Ответить
@Zanthous_
@Zanthous_ - 03.05.2022 22:24

i actually dont like the shorts format because you can't scroll through it at your own pace and you are forced to rewatch it

Ответить
@zekiozdemir420
@zekiozdemir420 - 03.05.2022 22:40

like

Ответить
@mementomori7160
@mementomori7160 - 03.05.2022 22:46

I do not like the short format, you can only stop it, you can't fast forward, go back, slow down, make it faster. Short video in normal format is much much better

Ответить
@PelipUnityDev
@PelipUnityDev - 03.05.2022 23:33

It`s awesone. THANKS!!!

Ответить
@WeenieWalkerGames
@WeenieWalkerGames - 04.05.2022 00:27

Great tip! Thank you for pointing it out.

Ответить
@blockman12345
@blockman12345 - 04.05.2022 01:13

❤️

Ответить
@SystemOfATool
@SystemOfATool - 04.05.2022 01:33

i hate this format because you can't go forward/back or change the speed of the video.

Ответить
@seppukun208
@seppukun208 - 04.05.2022 01:40

Knew about this for a while. Great tip nonetheless

Ответить
@realtimberstalker
@realtimberstalker - 04.05.2022 02:34

I remember learning about the field: specifier for attributes and tried it out with properties and it didn't serialize. I must have messed up because a few weeks ago I tried it again and it suddenly worked.

Ответить
@DoubleBob
@DoubleBob - 04.05.2022 03:33

This YT Shorts format is just bad. I wish you would have made an actual video about the topic.

Ответить
@user-em9su3dd9y
@user-em9su3dd9y - 04.05.2022 04:01

Love the Shorts format Jason!

Ответить
@gfusani
@gfusani - 04.05.2022 06:20

That's awesome! Thanks for sharing

Ответить
@damnpete
@damnpete - 04.05.2022 07:08

NOOOOOOOOOOOOOOOOO WAYYYYYYYYYYYY. I have been doing the annoying field & property because of [SerializeField] (can get around it with Custom Inspector but would be silly to make one just for that). I'm gonna test this now, this is gold!!!

Ответить
@maxfun6797
@maxfun6797 - 05.05.2022 09:37

I like this short but the only problem is, it can't rewind, or I can't rewind

Ответить
@JaemiHD
@JaemiHD - 05.05.2022 12:22

Hi Jason,
this is such a nice tip my code got so much cleaner, thank you!!!
Ich got a queston for you, why don´t you use internal instead of public, i think i never saw you use it. I would love to see a video in which you show the advantages, becouse may devs are concerned about the security of there code.
What do you think about internal :)?

Ответить
@michaelberna987
@michaelberna987 - 05.05.2022 22:38

Thanks Jason, this is great! Also, if you use Odin Inspector, you can do [Show in inspector] next to your field. Odin is actually quite a nice editor plugin for making inspectors. I recommend it (when it goes on sale or in a bundle of course)

Ответить
@rand1815
@rand1815 - 06.05.2022 19:32

This is a fantastic tip. I have always hated the clutter of adding backing fields to public getters. I am running into a problem adding these to my custom editor scripts though. I can access a private serializedfield from my class by finding with through serializedObject.FindProperty and then linking it to an EditorGUILayout.PropertyField but when I try to do the same with a property using this method I get an error that its null and my editor won't draw. Anyone have ideas on what I am missing? :)

Ответить
@StevenBloomfield
@StevenBloomfield - 07.05.2022 18:45

Awesome tip, thanks!

Ответить
@rafaaccr
@rafaaccr - 07.05.2022 21:54

😱😱😱😱😱😱✌🏻✌🏻✌🏻✌🏻✌🏻✌🏻✌🏻

Ответить
@09mrbubbles
@09mrbubbles - 23.05.2022 17:30

Is it possible to use this with a statement body? I need to enable/disable a component when my property is set. But this setup doesn't seem to like statement bodies for the get{} set{}

Ответить
@R3C_Tech
@R3C_Tech - 24.06.2022 22:52

You've unleashed one epic AF refactor...

Ответить
@donbolshoff8965
@donbolshoff8965 - 10.01.2023 18:54

You are the best, now I FINALLY can use interfaces effectively!!!

Ответить
@DennisDenchoDenchyaknow
@DennisDenchoDenchyaknow - 03.04.2023 19:14

Would be cool if it showed up in inspector. If not then I guess ima stick to a serialized private var with m_ 😂

Ответить
@risingforce9648
@risingforce9648 - 12.07.2024 19:13

only works for property that is get? not set? only get?

Ответить
@gaddgames
@gaddgames - 13.07.2024 22:00

Just wanted to thank you, about two years ago you came on a Discord call with me because I was stuck with my project and the lessons you taught me in that half an hour is the reason I am where I am today. :)

Ответить