private void OnTimelineStop() { CinemachineBrain brain = CameraControll.Instance.gameObject.GetComponent <CinemachineBrain>(); var vm = brain.GetComponentInChildren <CinemachineVirtualCamera>(); if (vm != null) { vm.gameObject.SetActive(false); } if (brain != null) { brain.enabled = false; } }
private void LoadAndSetTimelineBindingData(LoadedTimelineData data) { //这里可以得到每个track的绑定值,并进行一些设置,比如将绑定的类中的roleobject变量赋值 //这里还可以对每个track中的每个clip设置,可以取到每个clip的asset,并对其中的属性赋值,这样在creatplayable的时候,就会赋值到playable上 CinemachineBrain brain = CameraControll.Instance.gameObject.GetComponent <CinemachineBrain>(); if (brain == null) { brain = CameraControll.Instance.gameObject.AddComponent <CinemachineBrain>(); } brain.enabled = false; var childVm = brain.GetComponentInChildren <CinemachineVirtualCamera>(); if (childVm == null) { GameObject vitrualCa = new GameObject("VM", typeof(CinemachineVirtualCamera)); vitrualCa.transform.parent = brain.transform; vitrualCa.transform.localPosition = Vector3.zero; vitrualCa.transform.localEulerAngles = Vector3.zero; vitrualCa.transform.localScale = Vector3.one; var VM = vitrualCa.GetComponent <CinemachineVirtualCamera>(); VM.Priority = 1; } //List<RoleData> loadedRoleData = new List<RoleData>(); needLoadRoleData.Clear(); foreach (var binding in data.director.playableAsset.outputs) { if (binding.sourceObject is MYCinemachineTrack) { SetCinemachineTrackData(binding, data.director); continue; } UnityEngine.Object bindingObj = data.director.GetGenericBinding(binding.sourceObject); if (bindingObj != null && bindingObj is RoleData) { RoleData roledata = bindingObj as RoleData; if (!needLoadRoleData.Contains(roledata)) { //LoadBindingRoleData(roledata); needLoadRoleData.Add(roledata); } } } StartCoroutine(LoadBindingRoleData()); //StartCoroutine(InitVirtualCamera(data)); }