备份CatanBuilding瘦身独立工程
This commit is contained in:
44
Assets/Scripts/Core/CameraScroller.cs
Normal file
44
Assets/Scripts/Core/CameraScroller.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using System;
|
||||
|
||||
namespace Game
|
||||
{
|
||||
public class CameraScroller : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDragHandler
|
||||
{
|
||||
public bool isDragging { get; private set; }
|
||||
|
||||
float _yMax = 4.5f;
|
||||
float _yMin = -1f;
|
||||
|
||||
public void OnBeginDrag(PointerEventData eventData)
|
||||
{
|
||||
isDragging = true;
|
||||
}
|
||||
|
||||
public void OnDrag(PointerEventData eventData)
|
||||
{
|
||||
var main_cam = Camera.main;
|
||||
|
||||
if (main_cam != null)
|
||||
{
|
||||
var pos = main_cam.transform.position;
|
||||
var new_y = pos.y;
|
||||
new_y -= eventData.delta.y * 0.01f;
|
||||
pos.y = Mathf.Clamp(new_y, _yMin, _yMax);
|
||||
|
||||
main_cam.transform.position = pos;
|
||||
}
|
||||
}
|
||||
|
||||
public void OnEndDrag(PointerEventData eventData)
|
||||
{
|
||||
isDragging = false;
|
||||
}
|
||||
|
||||
public void OnPointerClick(PointerEventData eventData)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user