public Vector3 LimitersRegion() { cameraBounds.SetMinMax(new Vector3(cam.GetPosition().position.x - cam.CameraWidth() / 2, cam.GetPosition().position.y - cam.CameraHeight() / 2), new Vector3(cam.GetPosition().position.x + cam.CameraWidth() / 2, cam.GetPosition().position.y + cam.CameraHeight() / 2)); float _minX, _minY; boundMin.x = cameraLimits.min.x + cam.CameraWidth() / 2; boundMax.x = cameraLimits.max.x - cam.CameraWidth() / 2; boundMin.y = cameraLimits.min.y + cam.CameraHeight() / 2; boundMax.y = cameraLimits.max.y - cam.CameraHeight() / 2; _minX = Mathf.Clamp(cam.targetPosition.x + cam.offset.x, boundMin.x, boundMax.x); _minY = Mathf.Clamp(cam.targetPosition.y + cam.offset.y, boundMin.y, boundMax.y); return(new Vector3(_minX, _minY, cam.offset.z)); }
void OnDrawGizmos() { cam = GetComponent <CameraCore>(); deadZoneHeight = cam.CameraHeight() * height; deadZoneWidth = cam.CameraWidth() * width; if (useDeadZone) { Gizmos.color = Color.blue; Gizmos.DrawLine(new Vector3(cam.GetPosition().position.x - deadZoneWidth * 0.5f, cam.GetPosition().position.y - deadZoneHeight * 0.5f, 0), new Vector3(cam.GetPosition().position.x - deadZoneWidth * 0.5f, cam.GetPosition().position.y + deadZoneHeight * 0.5f, 0)); Gizmos.DrawLine(new Vector3(cam.GetPosition().position.x - deadZoneWidth * 0.5f, cam.GetPosition().position.y + deadZoneHeight * 0.5f, 0), new Vector3(cam.GetPosition().position.x + deadZoneWidth * 0.5f, cam.GetPosition().position.y + deadZoneHeight * 0.5f, 0)); Gizmos.DrawLine(new Vector3(cam.GetPosition().position.x + deadZoneWidth * 0.5f, cam.GetPosition().position.y + deadZoneHeight * 0.5f, 0), new Vector3(cam.GetPosition().position.x + deadZoneWidth * 0.5f, cam.GetPosition().position.y - deadZoneHeight * 0.5f, 0)); Gizmos.DrawLine(new Vector3(cam.GetPosition().position.x + deadZoneWidth * 0.5f, cam.GetPosition().position.y - deadZoneHeight * 0.5f, 0), new Vector3(cam.GetPosition().position.x - deadZoneWidth * 0.5f, cam.GetPosition().position.y - deadZoneHeight * 0.5f, 0)); } }