I have a ComponentSystem
that wants to perform raycast from camera.
I don’t want to use Camera.main inside OnUpdate
. I want to cache the camera somewhere and use that.
So what’s the best way to do it? Should I use SystemStateComponent
?
public class MyCameraSystem : ComponentSystem
{
Camera camera;
protected override void OnCreateManager()
{
camera = Camera.main; // reference here
}
protected override void OnUpdate( )
{
// use camera here
}
}
1 Like