unity 使用RenderTexture映射到UIRawImage上,拖拽Image旋转模型

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上

你可能感兴趣的:(unity,unity,游戏引擎)