Share the basic control script of the mouse finger sliding and rotating the model

rotation script

There are a lot of rotation scripts on the Internet. There is not much to say about this. The explanations are all in the code.

Originally just rotated the 3D model

Modified to support RenderTexture -> UI, and drag UI directly

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;

/// <summary>
/// 人物展示时的滑动旋转,可旋转模型;据说支持Mobile端操作,待测试;
/// </summary>
public class CharacterRotateController : MonoBehaviour
{
        [Header("点击的区域")]
        [SerializeField] private GameObject target;
        public GameObject touchTargetUI;
        [SerializeField] private float angle = 180f;
        public bool m_IsSwiping = false;
        private Vector3 m_PreviousTouch;

        private RectTransform _rect;

        //貌似 UI是 Overlay模式时不需要传入 camera_ui
        //Camera Cameras_UI;
        // S

Guess you like

Origin blog.csdn.net/avi9111/article/details/122567471