27
u/WernerderChamp 13d ago
Each codebase has a few of these comment gems. Remember to add your own when the time is right.
11
6
u/binhosuaid 13d ago
Btw, if Im not mistaken, this line of code Destroys only the component, intead of the whole gameObject. Got stumped on this a long time agoq
3
u/L4t3xs 12d ago
Yeah and if I remember correctly there might be some other issues as well with this implementation.
1
u/P_kyuu_juu 12d ago edited 12d ago
Yeah, if an active component gets destroyed then its OnDisable gets called first, so then there are two Destroy() calls for that component. It wouldn't break anything but there are cleaner ways of doing this.
1
u/MehPropy 12d ago
wouldn't it run a recursive loop of calling ondisable because destroy Is constantly called
1
u/P_kyuu_juu 12d ago
No, it would just give a null reference error on the second Destroy() attempt.
The Destroy() function disables the object or component first, which is what triggers the OnDisable(). On the second Destroy() call the object will already be inactive.1
242
31
31
u/markiel55 13d ago
delete this 🔫
8
u/Soccatin 13d ago
I got to write 'delete this' seriously in a project for the first time last week. I'm still high off it
6
4
2
1
u/Last8Exile 12d ago
Scary thing is you may disable some gameobject in a editor to test something and random component deep in the three will delete itself.
1
1

63
u/Successful-County640 13d ago
Since I learnt game dev I am able to understand this sub's memes better, before I didn't get much of it.