Advertisement
Guest User

Unity Mouse Scroll Wheel Mover

a guest
Mar 8th, 2023
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.49 KB | Software | 0 0
  1. using UnityEngine;
  2.  
  3. public class ScrollwheelMover : MonoBehaviour
  4. {
  5.     public float Speed = 0.1f;
  6.  
  7.     public void Update()
  8.     {
  9.         Vector2 delta = Input.mouseScrollDelta;
  10.         if(delta.y != 0f)
  11.         {
  12.             Vector3 newPosition = this.transform.position;
  13.             // Change either the .x to .y or .z if you want it to move in a different axis
  14.             newPosition.x += Speed * delta.y;
  15.            
  16.             this.transform.position = newPosition;
  17.         }
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement