Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

c# 14 added field backed properties where you dont need that `_health` in the first place you just write `public int Health { get => field; set => field = Mathf.Clamp(value, 0, 100)`. that way you never accidentally use the internal field without the checks. problem is unity still stuck on c# 9.0 so it might be years before you can actually use this in a game


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: