using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using HedgehogTeam.EasyTouch;
public class ModelController : MonoBehaviour
{
float deltaX;
float deltaY;
private void Awake()
{
EasyTouch.On_PinchIn += OnPinchIn;
EasyTouch.On_PinchOut += OnPinchOut;
}
private void OnDestroy()
{
EasyTouch.On_PinchIn -= OnPinchIn;
EasyTouch.On_PinchOut -= OnPinchOut;
}
private void OnPinchIn(Gesture g)
{
if(transform.localScale.x > 1)
{
float temp = Time.deltaTime * g.deltaPinch;
temp = transform.localScale.x - temp;
temp = temp < 1 ? 1 : temp;
transform.localScale = new Vector3(temp,temp,temp);
}
}
private void OnPinchOut(Gesture g)
{
if(transform.localScale.x < 4)
{
float temp = Time.deltaTime * g.deltaPinch;
temp = transform.localScale.x + temp;
temp = temp > 4 ? 4 : temp;
transform.localScale = new Vector3(temp, temp, temp);
}
}
// Update is called once per frame
void Update()
{
if (Input.GetMouseButton(0))
{
deltaY = -Input.GetAxisRaw("Mouse X") * 5f;
deltaX = Input.GetAxisRaw("Mouse Y") * 5f;
}
else
{
deltaX *= 0.9f;
deltaY *= 0.9f;
}
transform.Rotate(new Vector3(deltaX, deltaY, 0), Space.World);
}
}
网友评论