/// <summary> /// Try to find a CinemachineBrain to associate with a /// Cinemachine Virtual Camera. The first CinemachineBrain /// in which this Cinemachine Virtual Camera is live will be used. /// If none, then the first active CinemachineBrain with the correct /// layer filter will be used. /// Brains with OutputCamera == null will not be returned. /// Final result may be null. /// </summary> /// <param name="vcam">Virtual camera whose potential brain we need.</param> /// <returns>First CinemachineBrain found that might be /// appropriate for this vcam, or null</returns> public CinemachineBrain FindPotentialTargetBrain(CinemachineVirtualCameraBase vcam) { if (vcam != null) { int numBrains = BrainCount; for (int i = 0; i < numBrains; ++i) { CinemachineBrain b = GetActiveBrain(i); if (b != null && b.OutputCamera != null && b.IsLive(vcam)) { return(b); } } int layer = 1 << vcam.gameObject.layer; for (int i = 0; i < numBrains; ++i) { CinemachineBrain b = GetActiveBrain(i); if (b != null && b.OutputCamera != null && (b.OutputCamera.cullingMask & layer) != 0) { return(b); } } } return(null); }
/// <summary> /// Try to find a CinemachineBrain to associate with a /// Cinemachine Virtual Camera. The first CinemachineBrain /// in which this Cinemachine Virtual Camera is live will be used. /// If none, then the first active CinemachineBrain will be used. /// Brains with OutputCamera == null will not be returned. /// Final result may be null. /// </summary> /// <param name="vcam">Virtual camera whose potential brain we need.</param> /// <returns>First CinemachineBrain found that might be /// appropriate for this vcam, or null</returns> public CinemachineBrain FindPotentialTargetBrain(ICinemachineCamera vcam) { int numBrains = BrainCount; if (vcam != null && numBrains > 1) { for (int i = 0; i < numBrains; ++i) { CinemachineBrain b = GetActiveBrain(i); if (b != null && b.OutputCamera != null && b.IsLive(vcam)) { return(b); } } } for (int i = 0; i < numBrains; ++i) { CinemachineBrain b = GetActiveBrain(i); if (b != null && b.OutputCamera != null) { return(b); } } return(null); }
public CinemachineBrain FindPotentialTargetBrain(ICinemachineCamera vcam) { int brainCount = this.BrainCount; if (vcam != null && brainCount > 1) { for (int i = 0; i < brainCount; i++) { CinemachineBrain activeBrain = this.GetActiveBrain(i); if (activeBrain != null && activeBrain.OutputCamera != null && activeBrain.IsLive(vcam)) { return(activeBrain); } } } for (int j = 0; j < brainCount; j++) { CinemachineBrain activeBrain2 = this.GetActiveBrain(j); if (activeBrain2 != null && activeBrain2.OutputCamera != null) { return(activeBrain2); } } return(null); }
void DrawReticle(CinemachineBrain brain) { if (!brain.IsLive(VirtualCamera) || brain.OutputCamera == null) { CinemachineCore.CameraUpdatedEvent.RemoveListener(DrawReticle); } else if (AimTargetReticle != null) { AimTargetReticle.position = brain.OutputCamera.WorldToScreenPoint(AimTarget); } }
/// <summary> /// Signal that the virtual camera's content is discontinuous WRT the previous frame. /// If the camera is live, then all CinemachineBrains that are showing it will send a cut event. /// </summary> public void GenerateCameraCutEvent(ICinemachineCamera vcam) { if (vcam != null) { for (int i = 0; i < BrainCount; ++i) { CinemachineBrain b = GetActiveBrain(i); if (b != null && b.IsLive(vcam)) { b.m_CameraCutEvent.Invoke(b); } } } }
public void GenerateCameraCutEvent(ICinemachineCamera vcam) { if (vcam != null) { for (int i = 0; i < this.BrainCount; i++) { CinemachineBrain activeBrain = this.GetActiveBrain(i); if (activeBrain != null && activeBrain.IsLive(vcam)) { activeBrain.m_CameraCutEvent.Invoke(activeBrain); } } } }
/// <summary> /// Is this virtual camera currently actively controlling any Camera? /// </summary> public bool IsLive(ICinemachineCamera vcam) { if (vcam != null) { for (int i = 0; i < BrainCount; ++i) { CinemachineBrain b = GetActiveBrain(i); if (b != null && b.IsLive(vcam)) { return(true); } } } return(false); }
public bool IsLive(ICinemachineCamera vcam) { if (vcam != null) { for (int i = 0; i < this.BrainCount; i++) { CinemachineBrain activeBrain = this.GetActiveBrain(i); if (activeBrain != null && activeBrain.IsLive(vcam)) { return(true); } } } return(false); }
void DrawReticle(CinemachineBrain brain) { if (!brain.IsLive(VirtualCamera) || brain.OutputCamera == null) { CinemachineCore.CameraUpdatedEvent.RemoveListener(DrawReticle); } else { var player = VirtualCamera.Follow; if (AimTargetReticle != null && player != null) { // Adjust for actual player aim target (may be different due to offset) var playerPos = player.position; var aimTarget = VirtualCamera.State.ReferenceLookAt; var dir = aimTarget - playerPos; if (RuntimeUtility.RaycastIgnoreTag(new Ray(playerPos, dir), out RaycastHit hitInfo, dir.magnitude, AimCollisionFilter, IgnoreTag)) { aimTarget = hitInfo.point; } AimTargetReticle.position = brain.OutputCamera.WorldToScreenPoint(aimTarget); } } }