Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- [RequireComponent(typeof(Camera))]
- public class cameraScroll : MonoBehaviour {
- private float xvalorg;
- private float xvaldelta;
- public float scrollSpeed;
- Vector3 ThePosition;
- void Update () {
- if (Input.GetMouseButtonDown(0))
- {
- xvalorg = Input.mousePosition.x;
- }
- if (Input.GetMouseButton(0))
- {
- xvaldelta = Input.mousePosition.x;
- //if heigher than button area
- if (Input.mousePosition.y > 100f)
- {
- ThePosition = transform.position;
- ThePosition.x += (xvalorg - xvaldelta) * scrollSpeed;
- transform.position = ThePosition;
- }
- xvalorg = Input.mousePosition.x;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement