Exemplo n.º 1
0
 void Awake()
 {
     controller   = GetComponent <CharacterController>();
     smoothCamera = GetComponentInChildren <SmoothCameraWithBumper>();
     audioSource  = GetComponentInChildren <AudioSource>();
     anim         = GetComponent <Animation>();
 }
Exemplo n.º 2
0
        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 = UnityEngine.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());
        }
 void Awake()
 {
     controller = GetComponent<CharacterController>();
     smoothCamera = GetComponentInChildren<SmoothCameraWithBumper>();
     audioSource = GetComponentInChildren<AudioSource>();
     anim = GetComponent<Animation>();
 }
Exemplo n.º 4
0
        private void DrawCameraStage()
        {
            EditorGUILayout.LabelField("Camera", EditorStyles.boldLabel);
            EditorWindowTools.StartIndentedSection();
            UnityEngine.Camera     playerCamera = pcObject.GetComponentInChildren <UnityEngine.Camera>() ?? UnityEngine.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 <UnityEngine.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);
        }