private SetEnabledOnDialogueEvent.SetEnabledAction[] GetPlayerControls(SetEnabledOnDialogueEvent.SetEnabledAction[] oldList, Toggle state) { List <SetEnabledOnDialogueEvent.SetEnabledAction> actions = new List <SetEnabledOnDialogueEvent.SetEnabledAction>(); if (oldList != null) { actions.AddRange(oldList); } foreach (var component in pcObject.GetComponents <MonoBehaviour>()) { if (IsPlayerControlComponent(component) && !IsInActionList(actions, component)) { AddToActionList(actions, component, state); } } SmoothCameraWithBumper smoothCamera = pcObject.GetComponentInChildren <SmoothCameraWithBumper>(); if (smoothCamera == null) { smoothCamera = Camera.main.GetComponent <SmoothCameraWithBumper>(); } if ((smoothCamera != null) && !IsInActionList(actions, smoothCamera)) { AddToActionList(actions, smoothCamera, state); } actions.RemoveAll(a => ((a == null) || (a.target == null))); return(actions.ToArray()); }
private void DrawCameraStage() { EditorGUILayout.LabelField("Camera", EditorStyles.boldLabel); EditorWindowTools.StartIndentedSection(); Camera playerCamera = pcObject.GetComponentInChildren <Camera>() ?? Camera.main; SmoothCameraWithBumper smoothCamera = (playerCamera != null) ? playerCamera.GetComponent <SmoothCameraWithBumper>() : null; EditorGUILayout.BeginHorizontal(); bool useSmoothCamera = EditorGUILayout.Toggle((smoothCamera != null), GUILayout.Width(ToggleWidth)); EditorGUILayout.LabelField("Use Smooth Follow Camera", EditorStyles.boldLabel); EditorGUILayout.EndHorizontal(); if (useSmoothCamera) { if (playerCamera == null) { GameObject playerCameraObject = new GameObject("Player Camera"); playerCameraObject.transform.parent = pcObject.transform; playerCamera = playerCameraObject.AddComponent <Camera>(); playerCamera.tag = "MainCamera"; } smoothCamera = playerCamera.GetComponentInChildren <SmoothCameraWithBumper>() ?? playerCamera.gameObject.AddComponent <SmoothCameraWithBumper>(); EditorWindowTools.StartIndentedSection(); if (smoothCamera.target == null) { EditorGUILayout.HelpBox("Specify the transform (usually the head) that the camera should follow.", MessageType.Info); } smoothCamera.target = EditorGUILayout.ObjectField("Target", smoothCamera.target, typeof(Transform), true) as Transform; EditorWindowTools.EndIndentedSection(); } else { DestroyImmediate(smoothCamera); } if (GUILayout.Button("Select Camera", GUILayout.Width(100))) { Selection.activeObject = playerCamera; } EditorWindowTools.EndIndentedSection(); DrawNavigationButtons(true, true, false); }