Am I using registry.view<...>().front()) correctly or is this code messy? #1231
-
hello,
As you can see I have the two references variables (®istry and &cameraComponent). My question is if I am doing something weird The reason why I am doing this is to be able to access directly the cameraComponent in the update Without storing my cameraComonent as a reference variable I would have to do this in the update
which I guess won't have an big impact on performance since it is only one component and it is not doing anything crazy. Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Not a fan of storing references as members, but what you're doing is fine. At least, as long as you don't add other components of the same type. In that case, the reference can be invalidated due to a reallocation. |
Beta Was this translation helpful? Give feedback.
In this case, I'd implement it as a loop over the camera component from the beginning.
It doesn't hurt and you won't have to change it later on in case. 🤷♂️