|
@@ -8,7 +8,7 @@ using UnityEngine.EventSystems;
|
|
/// </summary>
|
|
/// </summary>
|
|
public class CameraController : MonoBehaviour
|
|
public class CameraController : MonoBehaviour
|
|
{
|
|
{
|
|
- public enum RotationAxes { MouseXAndY, MouseX, MouseY, RelativeObject, KeyBoard, Mouse }
|
|
|
|
|
|
+ public enum RotationAxes { MouseXAndY, MouseX, MouseY, RelativeObject, KeyBoard, Mouse, TrackMarker }
|
|
public RotationAxes axes = RotationAxes.MouseXAndY;
|
|
public RotationAxes axes = RotationAxes.MouseXAndY;
|
|
public float sensitivityX = 2F;
|
|
public float sensitivityX = 2F;
|
|
public float sensitivityY = 2F;
|
|
public float sensitivityY = 2F;
|
|
@@ -36,7 +36,9 @@ public class CameraController : MonoBehaviour
|
|
{
|
|
{
|
|
limit = Mathf.Abs(limit);
|
|
limit = Mathf.Abs(limit);
|
|
if (limit > 90) limit = 90;
|
|
if (limit > 90) limit = 90;
|
|
- if(axes != RotationAxes.Mouse)offset = new Vector3(offset.x, offset.y, offset.z/*-Mathf.Abs(zoomMax) / 2*/);
|
|
|
|
|
|
+ if (axes != RotationAxes.Mouse) offset = new Vector3(offset.x, offset.y, offset.z/*-Mathf.Abs(zoomMax) / 2*/);
|
|
|
|
+ else
|
|
|
|
+ offset = transform.position;
|
|
if(target != null) transform.position = target.position + offset;
|
|
if(target != null) transform.position = target.position + offset;
|
|
|
|
|
|
targetPosition = transform.position;
|
|
targetPosition = transform.position;
|
|
@@ -275,40 +277,56 @@ public class CameraController : MonoBehaviour
|
|
|
|
|
|
//if (!Input.GetMouseButton(2)) return;
|
|
//if (!Input.GetMouseButton(2)) return;
|
|
|
|
|
|
- if (Input.GetMouseButton(2))
|
|
|
|
|
|
+ if (Input.GetMouseButton(1))
|
|
{
|
|
{
|
|
Vector3 pos = Camera.main.ScreenToViewportPoint(Input.mousePosition - dragOrigin);
|
|
Vector3 pos = Camera.main.ScreenToViewportPoint(Input.mousePosition - dragOrigin);
|
|
if(pos.x < 0)
|
|
if(pos.x < 0)
|
|
- targetPosition -= transform.right * movementSpeed;
|
|
|
|
|
|
+ targetPosition -= transform.right * movementSpeed * 0.1f;
|
|
if (pos.x>0)
|
|
if (pos.x>0)
|
|
- targetPosition += transform.right * movementSpeed;
|
|
|
|
|
|
+ targetPosition += transform.right * movementSpeed * 0.1f;
|
|
if (pos.y > 0)
|
|
if (pos.y > 0)
|
|
- targetPosition -= transform.up * movementSpeed;
|
|
|
|
|
|
+ targetPosition -= transform.up * movementSpeed*0.1f;
|
|
if (pos.y < 0)
|
|
if (pos.y < 0)
|
|
- targetPosition += transform.up * movementSpeed;
|
|
|
|
|
|
+ targetPosition += transform.up * movementSpeed * 0.1f;
|
|
}
|
|
}
|
|
|
|
|
|
if (Input.GetAxis("Mouse ScrollWheel") > 0)
|
|
if (Input.GetAxis("Mouse ScrollWheel") > 0)
|
|
{
|
|
{
|
|
- offset.z += zoom;
|
|
|
|
|
|
+ //offset.z += zoom;
|
|
|
|
+ targetPosition += transform.forward * movementSpeed;
|
|
}
|
|
}
|
|
else if (Input.GetAxis("Mouse ScrollWheel") < 0)
|
|
else if (Input.GetAxis("Mouse ScrollWheel") < 0)
|
|
- offset.z -= zoom;
|
|
|
|
- offset.z = Mathf.Clamp(offset.z, -Mathf.Abs(zoomMax), -Mathf.Abs(zoomMin));
|
|
|
|
-
|
|
|
|
- transform.position = transform.localRotation * offset;
|
|
|
|
-
|
|
|
|
- if (Input.GetMouseButton(1))
|
|
|
|
{
|
|
{
|
|
- Cursor.visible = false;
|
|
|
|
- targetRotationY += Input.GetAxis("Mouse X") * rotationSpeed;
|
|
|
|
- targetRotationX -= Input.GetAxis("Mouse Y") * rotationSpeed;
|
|
|
|
- targetRotation = Quaternion.Euler(targetRotationX, targetRotationY, 0.0f);
|
|
|
|
|
|
+ //offset.z -= zoom;
|
|
|
|
+ targetPosition -= transform.forward * movementSpeed;
|
|
}
|
|
}
|
|
- else
|
|
|
|
- Cursor.visible = true;
|
|
|
|
|
|
+ //offset.z = Mathf.Clamp(offset.z, -Mathf.Abs(zoomMax), -Mathf.Abs(zoomMin));
|
|
|
|
|
|
- transform.position = Vector3.Lerp(transform.position, targetPosition, (1.0f - smoothness));
|
|
|
|
- transform.rotation = Quaternion.Lerp(transform.rotation, targetRotation, (1.0f - smoothness));
|
|
|
|
|
|
+ //if (Input.GetAxis("Mouse ScrollWheel") != 0)
|
|
|
|
+ //{
|
|
|
|
+
|
|
|
|
+ // X = transform.localEulerAngles.y + Input.GetAxis("Mouse X") * sensitivity;
|
|
|
|
+ // Y += Input.GetAxis("Mouse Y") * sensitivity;
|
|
|
|
+ // Y = Mathf.Clamp(Y, -limit, limit);
|
|
|
|
+ // //transform.localEulerAngles = new Vector3(-Y, X, 0);
|
|
|
|
+ // transform.position = new Vector3(transform.position.x, Y, transform.position.z);
|
|
|
|
+
|
|
|
|
+ //}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ //transform.position = transform.localRotation * offset;
|
|
|
|
+
|
|
|
|
+ //if (Input.GetMouseButton(1))
|
|
|
|
+ //{
|
|
|
|
+ // Cursor.visible = false;
|
|
|
|
+ // targetRotationY += Input.GetAxis("Mouse X") * rotationSpeed;
|
|
|
|
+ // targetRotationX -= Input.GetAxis("Mouse Y") * rotationSpeed;
|
|
|
|
+ // targetRotation = Quaternion.Euler(targetRotationX, targetRotationY, 0.0f);
|
|
|
|
+ //}
|
|
|
|
+ //else
|
|
|
|
+ // Cursor.visible = true;
|
|
|
|
+
|
|
|
|
+ transform.position = Vector3.Lerp(transform.position, targetPosition, (1.0f - smoothness));
|
|
|
|
+ //transform.rotation = Quaternion.Lerp(transform.rotation, targetRotation, (1.0f - smoothness));
|
|
}
|
|
}
|
|
}
|
|
}
|