Zone View Mousedrag & Background Parallax
This commit is contained in:
parent
4221f304f1
commit
6dd43fc193
9 changed files with 113 additions and 5 deletions
22
Assets/DragHandler.cs
Normal file
22
Assets/DragHandler.cs
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class DragHandler : MonoBehaviour
|
||||
{
|
||||
public Camera Camera;
|
||||
public float Scaling;
|
||||
private Vector2 _previousPosition;
|
||||
|
||||
void Update()
|
||||
{
|
||||
var newPosition = Camera.ScreenToWorldPoint(Input.mousePosition);
|
||||
if(Input.GetMouseButtonDown(0))
|
||||
_previousPosition = newPosition;
|
||||
if (Input.GetMouseButton(0))
|
||||
{
|
||||
Camera.transform.position -= (Vector3)((Vector2) newPosition - _previousPosition);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue