public void Pan(object sender, ScreenEdgeEventArgs e) { if (canWeScroll) { float totalSpeed = e.duration * ScrollAcceleration; float targetSpeed = totalSpeed < ScrollSpeed ? totalSpeed : ScrollSpeed; transform.Translate(e.x * Time.deltaTime * targetSpeed, 0, e.y * Time.deltaTime * targetSpeed, Space.World); //Check if we have scrolled past edge if (transform.position.x < m_Boundries.xMin) { transform.position = new Vector3(m_Boundries.xMin, transform.position.y, transform.position.z); } else if (transform.position.x > m_Boundries.xMax) { transform.position = new Vector3(m_Boundries.xMax, transform.position.y, transform.position.z); } if (transform.position.z < m_Boundries.yMin) { transform.position = new Vector3(transform.position.x, transform.position.y, m_Boundries.yMin); } else if (transform.position.z > m_Boundries.yMax) { transform.position = new Vector3(transform.position.x, transform.position.y, m_Boundries.yMax); } CheckEdgeMovement(); } }
public void Pan(object sender, ScreenEdgeEventArgs e) { if (canWeScroll) { float totalSpeed = e.duration*ScrollAcceleration; float targetSpeed = totalSpeed < ScrollSpeed ? totalSpeed : ScrollSpeed; transform.Translate (e.x*Time.deltaTime*targetSpeed, 0, e.y*Time.deltaTime*targetSpeed, Space.World); //Check if we have scrolled past edge if (transform.position.x < m_Boundries.xMin) { transform.position = new Vector3(m_Boundries.xMin, transform.position.y, transform.position.z); } else if (transform.position.x > m_Boundries.xMax) { transform.position = new Vector3(m_Boundries.xMax, transform.position.y, transform.position.z); } if (transform.position.z < m_Boundries.yMin) { transform.position = new Vector3(transform.position.x, transform.position.y, m_Boundries.yMin); } else if (transform.position.z > m_Boundries.yMax) { transform.position = new Vector3(transform.position.x, transform.position.y, m_Boundries.yMax); } CheckEdgeMovement (); } }
private void MouseAtScreenEdgeHandler(ScreenEdgeEventArgs e) { //Camera Screen Move float newX = myCamera.transform.position.x; float newY = myCamera.transform.position.y; float newZ = myCamera.transform.position.z; float amount = 0.3f; if (e.screenEdgeEventType == ScreenEdgeEventType.Up) { newZ += amount; pos.Set(newX, newY, newZ); myCamera.transform.position = pos; } else if (e.screenEdgeEventType == ScreenEdgeEventType.Down) { newZ -= amount; pos.Set(newX, newY, newZ); myCamera.transform.position = pos; } else if (e.screenEdgeEventType == ScreenEdgeEventType.Right) { newX += amount; pos.Set(newX, newY, newZ); myCamera.transform.position = pos; } else if (e.screenEdgeEventType == ScreenEdgeEventType.Left) { newX -= amount; pos.Set(newX, newY, newZ); myCamera.transform.position = pos; } }
private void MouseAtScreenEdgeHandler(object sender, ScreenEdgeEventArgs e) { //Pan m_Camera.Pan (sender, e); m_MiniMapController.ReCalculateViewRect (); }
private void MouseAtScreenEdgeHandler(object sender, ScreenEdgeEventArgs e) { //Pan m_Camera.Pan(sender, e); m_MiniMapController.ReCalculateViewRect(); }
private void CheckScreenEdgeEvents() { ScreenEdgeEventArgs tempEventArgs = null; atScreenEdge = false; if (Input.mousePosition.x == 0) { if (tempEventArgs == null) { tempEventArgs = new ScreenEdgeEventArgs(-1, 0); } else { tempEventArgs.x = -1; } atScreenEdge = true; } if (Input.mousePosition.x == Screen.width - 1) { if (tempEventArgs == null) { tempEventArgs = new ScreenEdgeEventArgs(1, 0); } else { tempEventArgs.x = 1; } atScreenEdge = true; } if (Input.mousePosition.y == 0) { if (tempEventArgs == null) { tempEventArgs = new ScreenEdgeEventArgs(0, -1); } else { tempEventArgs.y = -1; } atScreenEdge = true; } if (Input.mousePosition.y == Screen.height - 1) { if (tempEventArgs == null) { tempEventArgs = new ScreenEdgeEventArgs(0, 1); } else { tempEventArgs.y = 1; } atScreenEdge = true; } if (atScreenEdge) { atScreenEdgeCounter += Time.deltaTime; tempEventArgs.duration = atScreenEdgeCounter; } else { atScreenEdgeCounter = 0; } if (tempEventArgs != null && ScreenEdgeMousePosition != null) { ScreenEdgeMousePosition(this, tempEventArgs); } }
private void CheckScreenEdgeEvents() { ScreenEdgeEventArgs tempEventArgs = null; atScreenEdge = false; if (Input.mousePosition.x == 0) { if (tempEventArgs == null) { tempEventArgs = new ScreenEdgeEventArgs(-1, 0); } else { tempEventArgs.x = -1; } atScreenEdge = true; } if (Input.mousePosition.x >= Screen.width * 0.98f) { if (tempEventArgs == null) { tempEventArgs = new ScreenEdgeEventArgs(1, 0); } else { tempEventArgs.x = 1; } atScreenEdge = true; } if (Input.mousePosition.y == 0) { if (tempEventArgs == null) { tempEventArgs = new ScreenEdgeEventArgs(0, -1); } else { tempEventArgs.y = -1; } atScreenEdge = true; } if (Input.mousePosition.y >= Screen.height * 0.98f) { if (tempEventArgs == null) { tempEventArgs = new ScreenEdgeEventArgs(0, 1); } else { tempEventArgs.y = 1; } atScreenEdge = true; } if (atScreenEdge) { atScreenEdgeCounter += Time.deltaTime; tempEventArgs.duration = atScreenEdgeCounter; } else { atScreenEdgeCounter = 0; } if (tempEventArgs != null && ScreenEdgeMousePosition != null) { ScreenEdgeMousePosition(this, tempEventArgs); } }