Advertisement
Wolvenspud

EW - cameraScroll

Oct 7th, 2017
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.82 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. [RequireComponent(typeof(Camera))]
  5.  
  6. public class cameraScroll : MonoBehaviour {
  7.  
  8.     private float xvalorg;
  9.     private float xvaldelta;
  10.  
  11.     public float scrollSpeed;
  12.  
  13.     Vector3 ThePosition;
  14.  
  15.     void Update () {
  16.         if (Input.GetMouseButtonDown(0))
  17.         {
  18.             xvalorg = Input.mousePosition.x;
  19.         }
  20.         if (Input.GetMouseButton(0))
  21.         {
  22.             xvaldelta = Input.mousePosition.x;
  23.  
  24.             //if heigher than button area
  25.             if (Input.mousePosition.y > 100f)
  26.             {
  27.                 ThePosition = transform.position;
  28.                 ThePosition.x += (xvalorg - xvaldelta) * scrollSpeed;
  29.                 transform.position = ThePosition;
  30.             }
  31.             xvalorg = Input.mousePosition.x;
  32.         }
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement