Here is a script I wrote which you can apply to your existing 3D camera in order to perform various functions such as zooming, dragging, or panning the main camera. It worked best for me in a chess game I was writing while learning Unity, in which I had to display a chess board to the user and allow him to move around the board inside of the game.
using UnityEngine; public class Scene : MonoBehaviour { Vector3 lastDragPosition, lastPanPosition; void Update() { UpdateZoom(); UpdateDrag(); UpdatePan(); } void UpdateZoom() { var isMoving = Mathf.Abs(Input.mouseScrollDelta.y) > 0; if (!isMoving) return; var isZoomingIn = Input.mouseScrollDelta.y > 0; transform.position = transform.position + transform.forward.normalized * Time.deltaTime * (isZoomingIn ? 15f : -15f); } void UpdateDrag() { if (Input.GetMouseButtonDown(2)) lastDragPosition = Input.mousePosition; if (!Input.GetMouseButton(2)) return; var delta = lastDragPosition - Input.mousePosition; transform.Translate(delta * Time.deltaTime * 0.5f); lastDragPosition = Input.mousePosition; } void UpdatePan() { if (Input.GetMouseButtonDown(1)) lastPanPosition = Input.mousePosition; if (!Input.GetMouseButton(1)) return; var delta = lastPanPosition - Input.mousePosition; transform.RotateAround(transform.position, Vector3.up, delta.normalized.x * Time.deltaTime * 25f); transform.RotateAround(transform.position, transform.right, -delta.normalized.y * Time.deltaTime * 25f); lastPanPosition = Input.mousePosition; } }