public void UpdatePlayerNb(int playerNb) { normalView.name = "MainCameraRPG" + playerNb; //CameraShaker.ChangeNameOfInstance(faceCamera.name, "FaceCamera"+playerNb); cinemachineBrain.gameObject.layer = 15 + playerNb; normalView.gameObject.layer = 15 + playerNb; cinemachineBrain.GetComponent <Camera>().cullingMask |= (int)Mathf.Pow(2, (15 + playerNb)); }
static void ApplyPostFX(CinemachineBrain brain) { //UnityEngine.Profiling.Profiler.BeginSample("CinemachinePostProcessing.ApplyPostFX"); PostProcessLayer ppLayer = brain.GetComponent <PostProcessLayer>(); if (ppLayer == null || !ppLayer.enabled || ppLayer.volumeLayer == 0) { return; } CameraState state = brain.CurrentCameraState; int numBlendables = state.NumCustomBlendables; List <PostProcessVolume> volumes = GetDynamicBrainVolumes(brain, ppLayer, numBlendables); for (int i = 0; i < volumes.Count; ++i) { volumes[i].weight = 0; volumes[i].sharedProfile = null; volumes[i].profile = null; } for (int i = 0; i < numBlendables; ++i) { var b = state.GetCustomBlendable(i); CinemachinePostProcessing src = b.m_Custom as CinemachinePostProcessing; if (!(src == null)) // in case it was deleted { PostProcessVolume v = volumes[i]; v.sharedProfile = src.Profile; v.isGlobal = true; v.priority = float.MaxValue - 1; v.weight = b.m_Weight; } } //UnityEngine.Profiling.Profiler.EndSample(); }
private static void ApplyPostFX(CinemachineBrain brain) { PostProcessLayer component = brain.GetComponent <PostProcessLayer>(); if (component == null || !component.enabled || component.volumeLayer == 0) { return; } CameraState currentCameraState = brain.CurrentCameraState; int numCustomBlendables = currentCameraState.NumCustomBlendables; List <PostProcessVolume> dynamicBrainVolumes = CinemachinePostProcessing.GetDynamicBrainVolumes(brain, component, numCustomBlendables); for (int i = 0; i < dynamicBrainVolumes.Count; i++) { dynamicBrainVolumes[i].weight = 0f; dynamicBrainVolumes[i].sharedProfile = null; dynamicBrainVolumes[i].profile = null; } for (int j = 0; j < numCustomBlendables; j++) { CameraState.CustomBlendable customBlendable = currentCameraState.GetCustomBlendable(j); CinemachinePostProcessing cinemachinePostProcessing = customBlendable.m_Custom as CinemachinePostProcessing; if (!(cinemachinePostProcessing == null)) { PostProcessVolume postProcessVolume = dynamicBrainVolumes[j]; postProcessVolume.sharedProfile = cinemachinePostProcessing.Profile; postProcessVolume.isGlobal = true; postProcessVolume.priority = float.MaxValue; postProcessVolume.weight = customBlendable.m_Weight; } } }
// Start is called before the first frame update void Start() { virtualCamera = GetComponent <CinemachineVirtualCameraBase>(); brain = FindObjectOfType <CinemachineBrain>(); cam = brain.GetComponent <Camera>(); brain.m_CameraActivatedEvent.AddListener(CameraActivatedEvent); }
static void StaticPostFXHandler(CinemachineBrain brain) { PostProcessLayer postFX = brain.PostProcessingComponent as PostProcessLayer; if (postFX == null) { brain.PostProcessingComponent = brain.GetComponent <PostProcessLayer>(); postFX = brain.PostProcessingComponent as PostProcessLayer; if (postFX != null) { brain.m_CameraCutEvent.AddListener(CinemachinePostProcessing.OnCameraCut); } } if (postFX != null) { CinemachinePostProcessing.ApplyPostFX(brain); } }
private static void StaticPostFXHandler(CinemachineBrain brain) { PostProcessLayer x = brain.PostProcessingComponent as PostProcessLayer; if (x == null) { brain.PostProcessingComponent = brain.GetComponent <PostProcessLayer>(); x = (brain.PostProcessingComponent as PostProcessLayer); if (x != null) { brain.m_CameraCutEvent.AddListener(new UnityAction <CinemachineBrain>(CinemachinePostProcessing.OnCameraCut)); } } if (x != null) { CinemachinePostProcessing.ApplyPostFX(brain); } }
static void StaticPostFXHandler(CinemachineBrain brain) { CinemachinePostFX postFX = brain.PostProcessingComponent as CinemachinePostFX; if (postFX == null) { brain.PostProcessingComponent = brain.GetComponent <CinemachinePostFX>(); postFX = brain.PostProcessingComponent as CinemachinePostFX; if (postFX != null) { postFX.ConnectToBrain(); } } if (postFX != null) { postFX.PostFXHandler(brain); } }
static PostProcessLayer GetPPLayer(CinemachineBrain brain) { PostProcessLayer layer = null; if (mBrainToLayer.TryGetValue(brain, out layer)) { #if UNITY_EDITOR // Maybe they added it since we last checked if (layer != null || Application.isPlaying) #endif return(layer); } layer = brain.GetComponent <PostProcessLayer>(); mBrainToLayer[brain] = layer; if (layer != null) { brain.m_CameraCutEvent.AddListener(OnCameraCut); } else { brain.m_CameraCutEvent.RemoveListener(OnCameraCut); } return(layer); }