using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
public class UIRotationModels : MonoBehaviour, IDragHandler
{
///
/// 需要旋转的模型
///
public Transform m_TargetModles;
///
/// 速度
///
public float rotationSpeed = 10.0f;
public void OnDrag(PointerEventData eventData)
{
float deltaX = eventData.delta.x;
float rotationAmount = deltaX * rotationSpeed * Time.deltaTime;
m_TargetModles.Rotate(Vector3.up, -rotationAmount);
}
}
脚本放到Image上