3 ms·
I think I know the answer, but I'll ask explicitly. Suppose we have two components: A and B. A is defined to `RequireComponent` B. If I do `has(object, A) && h
by gugagore 6y ago
I think I know the answer, but I'll ask explicitly.
Suppose we have two components: A and B. A is defined to `RequireComponent` B. If I do `has(object, A) && has(object, B)` then can the C# compiler compile away the check for B given the check for A, turning it into just `has(object, A)`?
- linkdd 6y agoUnfortunately no. IIRC, all "RequireComponent" does is allow you to omit the "add(object, B)" when you "add(object, A)". A simple example of this is when you add A to the object, then edit A to require B. The Unity Editor won't add B automatically (which is in fact a pain). NB: removing A will not remove B, and B won't be replaced if it existed before. I usually use "RequireComponent" whenever I have a "GetComponent<...>()" in my behaviour just to make sure I have an initialized value.