#check if component marked for destruction

1 messages · Page 1 of 1 (latest)

livid mulch
#

Hey, I have a state machine for "CameraState", example for state: "FirstPersonCamera", "ThirdPersonCamera" "CutsceneControlledCamera".
the camera is controlled via CinemachineCamera which I just add or remove components from.
when swapping state, I remove the old component and enter a new one, but this happens on a different script,
when swapping, I would like to add a verification that the previous, old state has destroyed it's Cinemachine component (in Cinemachine 3.0, it's just a regular component).
but because this happens on the same frame, calling Destroy(oldComponent); does not actually remove it until the end of the frame.
so I would like to check if it is marked for destruction, before adding the new component, on the same frame, unless you know a better way.
thanks!

serene hound