Zoom using mouse scroll or touch: Unity Tutorial

This article explains how to zoom using mouse scroll or touch in unity.

I am going to use below scene for the example.

Zoom using mouse scroll or touch - Scene

Zoom using mouse scroll or touch (pinch to zoom)

Attach the below given script to the Main Camera GameObject. To get the zoom effect, below script changes the field of view of the camera (Orthographic) upon mouse or touch inputs.

Now run the application in unity and use mouse scroll button to zoom.

Zoom using mouse scroll or touch - Windows Output

Build the project for android platform and install it in android device. I have tested it with android Marshmallow and the zoom was working fine.

Zoom using mouse scroll or touch - Android output

Hope, you get an idea to zoom using mouse scroll or touch in unity application. Post your comments for queries and feedback. Thanks for reading.

Share Button
The following two tabs change content below.
Gyanendu Shekhar is a technology enthusiast. He loves to learn new technologies. His area of interest includes Microsoft technologies, Augmented reality, Virtual reality, unity3d and android development.

Gyanendu Shekhar

Gyanendu Shekhar is a technology enthusiast. He loves to learn new technologies. His area of interest includes Microsoft technologies, Augmented reality, Virtual reality, unity3d and android development.

Leave a Reply

Your email address will not be published. Required fields are marked *