Unity Quickies: Zooming, Dragging, and Panning the Camera in 3D Space

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()

    void UpdateZoom()
        var isMoving = Mathf.Abs(Input.mouseScrollDelta.y) > 0;
        if (!isMoving)
        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))
        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))
        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;

How to Find the Hash Rate of a GPU for Mining Ethereum on Windows

I have a laptop with the GeForce GTX 980M on it. I want to find out what my hash rate is to see what my profits could be from mining Ethereum over the Windows platform. Here’s how to do this:

  • Download the latest release of ethminer. Make sure to download theĀ Latest release and not theĀ Pre-release. Unzip it somewhere.
  • Open the command prompt to where you downloaded and unzipped ethminer. Run the ethminer -U -M command:
 C:\Downloads\ethminer-0.11.0-Windows>ethminer -U -M
 Using grid size 8192, block size 128
 Benchmarking on platform: CUDA
 Preparing DAG for block #0
 Warming up...
 i 13:04:52|cudaminer0 set work; seed: #00000000, target: #000000000000
 i 13:04:52|cudaminer0 Initialising miner...
 Using device: GeForce GTX 980M (Compute 5.2)
 Generating DAG for GPU #0
 CUDA#0: 0%
 CUDA#0: 6%
 CUDA#0: 13%
 CUDA#0: 19%
 CUDA#0: 25%
 CUDA#0: 31%
 CUDA#0: 38%
 CUDA#0: 44%
 CUDA#0: 50%
 CUDA#0: 56%
 CUDA#0: 63%
 CUDA#0: 69%
 CUDA#0: 75%
 CUDA#0: 81%
 CUDA#0: 88%
 CUDA#0: 94%
 Trial 1... 13277536
 Trial 2... 12578719
 Trial 3... 13273113
 Trial 4... 12570341
 Trial 5... 13277536
 min/mean/max: 12570341/12995449/13277536 H/s
 inner mean: 13043122 H/s
  • The inner mean is your hash rate. I’m sitting at about 13043122 H/s, which according to some online mining profitability calculator, could earn me about $30.45 / month if I don’t have to pay for electricity.