public override bool RegisterCamera(int playerIndex, PlayerCamera camera) { if (base.RegisterCamera(playerIndex, camera)) { playerCameraComponent[playerIndex - 1].orthographic = true; playerCameraComponent[playerIndex - 1].orthographicSize = splitScreenCamera.orthographicSize; return(true); } return(false); }
public override bool RegisterCamera(int playerIndex, PlayerCamera camera) { if (base.RegisterCamera(playerIndex, camera)) { playerCameraComponent[playerIndex - 1].orthographic = false; playerCameraComponent[playerIndex - 1].fieldOfView = splitScreenCamera.fieldOfView; playerCameraComponent[playerIndex - 1].aspect = splitScreenCamera.aspect; return(true); } return(false); }
/// <summary> /// Register camera for player with specified player index. /// </summary> /// <param name="playerIndex">player index should be in range 1-2</param> /// <param name="camera"></param> /// <returns></returns> public virtual bool RegisterCamera(int playerIndex, PlayerCamera camera) { playerIndex--; if (playerIndex >= 0 && playerIndex < 2) { playerCamera[playerIndex] = camera; playerCameraComponent[playerIndex] = camera.Camera; playerCameraTransform[playerIndex] = camera.transform; playerCameraTransform[playerIndex].rotation = splitScreenCamera.transform.rotation; return(true); } else { Debug.LogError("Wrong index passed to SplitScreenController.RegisterCamera()"); return(false); } }
public void RegisterPlayer(Transform player) { if (player1 == null) { player1 = player.transform; GameObject cam1 = Instantiate(PlayerCameraPrefab); cam1.name = "Player 1 camera"; player1Camera = cam1.GetComponent <PlayerCamera>(); splitScreen.RegisterCamera(1, player1Camera); } else if (player2 == null) { player2 = player.transform; GameObject cam2 = Instantiate(PlayerCameraPrefab); cam2.name = "Player 2 camera"; player2Camera = cam2.GetComponent <PlayerCamera>(); splitScreen.RegisterCamera(2, player2Camera); } TryEnableSplitScreen(); }