private void UpdateFreeView(SpaceShipExternalCamera camera) { float mouseX = Input.GetAxis("Mouse X") * m_PanSpeed; float mouseY = Input.GetAxis("Mouse Y") * -m_PanSpeed; // Add the new rotation delta to the current pan value camera.Pan += new Vector2(mouseY, mouseX); }
public SpaceShipExternalCamera GetExternalCamera(string name) { SpaceShipExternalCamera camera = null; if (m_ExternalCameras.TryGetValue(name.GetHashCode(), out camera)) { return(camera); } return(null); }
// Use this for initialization void Awake() { CelestialBodyLoader.PrefabPath = "Prefabs/CelestialBodies/"; // This must be done first. With no celestial objects, space is EMPTY!! { // Initialization cannot fail but will log warnings for any data it fails to load // All planets loaded will start with a base view position of origin CelestialManagerPhysical.Instance.Init(Application.dataPath + "/StreamingAssets/Config/CelestialBodies/"); if (m_MainLight != null) { CelestialBody sol = CelestialManagerPhysical.Instance.GetCelestialBody("Sol"); if (sol != null) { m_MainLight.transform.parent = sol.transform; } } CelestialBody rocinante = CelestialManagerPhysical.Instance.GetCelestialBody("Rocinante"); if (rocinante != null) { m_SpaceShip = rocinante as CelestialShip; // Connect cameras to the spaceship if (m_UICameraViewsParent != null) { ExternalShipView[] viewList = m_UICameraViewsParent.GetComponentsInChildren <ExternalShipView>(); foreach (ExternalShipView view in viewList) { // Does ship have this view? SpaceShipExternalCamera camera = m_SpaceShip.GetExternalCamera(view.name); if (camera != null) { view.m_ViewCamera = camera; } } } } } }
public void SetView(ExternalShipView view) { if (m_CurrentView != view) { if (m_CurrentView != null) { m_CurrentView.Select(false); } m_CurrentView = view; } //m_ViewCamera = view.m_ViewCamera; RawImage currentRawImage = GetComponent <RawImage>(); if (currentRawImage != null) { RawImage newRawImage = view.GetComponent <RawImage>(); if (newRawImage != null) { currentRawImage.texture = newRawImage.texture; } } if (m_LabelName != null) { m_LabelName.text = view.GetLabel(); } if (m_LabelZoom != null) { SpaceShipExternalCamera camera = m_CurrentView.m_ViewCamera; if (camera != null) { m_LabelZoom.text = "Zoom: x" + camera.GetZoom().ToString(); } } }
// Update is called once per frame private void Update() { if (MouseScreenCheck()) { if (m_DefaultView != null) { SpaceShipExternalCamera camera = m_CurrentView.m_ViewCamera; if (camera != null) { // Pan control if (Input.GetMouseButton(1)) { float mouseX = Input.GetAxis("Mouse X") * m_PanSpeed; float mouseY = Input.GetAxis("Mouse Y") * -m_PanSpeed; if (Cursor.lockState != CursorLockMode.Locked) { Cursor.lockState = CursorLockMode.Locked; if (Cursor.visible) { Cursor.visible = false; } } else { // Add the new rotation delta to the current pan value camera.Pan = new Vector2(mouseY, mouseX); //UpdateFreeView( camera ); } m_MouseBase = new Vector2(mouseX, mouseY); } else { if (Cursor.lockState == CursorLockMode.Locked) { Cursor.lockState = CursorLockMode.None; } if (Cursor.visible == false) { Cursor.visible = true; } } // Zoom control uint currentZoom = camera.GetZoom(); float mouseWheelValue = Input.GetAxis("Mouse ScrollWheel"); if (0.0f != mouseWheelValue) { int zoomChange = (int)(mouseWheelValue * m_ZoomSpeed); camera.ChangeZoom(zoomChange); currentZoom = camera.GetZoom(); } if (m_OldZoom != currentZoom) { m_LabelZoom.text = "Zoom: x" + currentZoom.ToString(); m_OldZoom = currentZoom; } } } } }