对拖拽模型水平旋转的脚本控制最佳做法

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
using UnityEngine;
using System.Collections;

namespace UnityEngine.UI
{
public class Empty4Raycast : MaskableGraphic
{
protected Empty4Raycast()
{
useLegacyMeshGeneration = false;
}

protected override void OnPopulateMesh(VertexHelper toFill)
{
toFill.Clear();
}
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using Res_Table;
using UnityEngine.UI;
using UnityEngine.EventSystems;

public class ModelDragController : MonoBehaviour,IDragHandler
{
private Vector2 m_Angle = Vector2.zero;
public Transform m_cTrans;

public void OnDrag(PointerEventData eventData)
{
m_Angle.y = -eventData.delta.x;
if (m_cTrans != null)
m_cTrans.Rotate(m_Angle);
}
}

End.