siyao
3 年前
当前提交
e20612cb
共有 10 个文件被更改,包括 165 次插入 和 61 次删除
-
13AwesomeUIWidgets/Assets/Prefabs/Cube.prefab
-
13AwesomeUIWidgets/Assets/Prefabs/Cylinder.prefab
-
15AwesomeUIWidgets/Assets/Prefabs/Sphere.prefab
-
87AwesomeUIWidgets/Assets/Scenes/RaycastablePickerRoom.unity
-
47AwesomeUIWidgets/Assets/Scripts/RaycastableScene/GameObjectManager.cs
-
2AwesomeUIWidgets/Assets/Scripts/RaycastableScene/ItemPickerMainUIPanel.cs
-
1AwesomeUIWidgets/Assets/Scripts/RaycastableScene/LeftUIPanel.cs
-
7AwesomeUIWidgets/Assets/Scripts/RaycastableScene/RaycastableSceneConfig.cs
-
38AwesomeUIWidgets/Assets/Scripts/RaycastableScene/DragRotate.cs
-
3AwesomeUIWidgets/Assets/Scripts/RaycastableScene/DragRotate.cs.meta
|
|||
using System; |
|||
using UnityEngine; |
|||
using UnityEngine.EventSystems; |
|||
using UInput = UnityEngine.Input; |
|||
|
|||
namespace UIWidgetsSample.RaycastableScene |
|||
{ |
|||
public class DragRotate : MonoBehaviour |
|||
{ |
|||
Vector2? _lastPosition = Vector2.zero; |
|||
|
|||
public static Vector2 mousePosition |
|||
{ |
|||
get |
|||
{ |
|||
return new Vector2(UInput.mousePosition.x, UInput.mousePosition.y); |
|||
} |
|||
} |
|||
|
|||
void OnMouseDown() |
|||
{ |
|||
_lastPosition = mousePosition; |
|||
} |
|||
|
|||
private void OnMouseUp() |
|||
{ |
|||
_lastPosition = null; |
|||
} |
|||
|
|||
private void OnMouseDrag() |
|||
{ |
|||
Vector2 direction = mousePosition - _lastPosition.Value; |
|||
_lastPosition = mousePosition; |
|||
|
|||
transform.Rotate(-direction.y, -direction.x, 0, Space.World); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 70433a8c34b64295acbc20adc0a670f5 |
|||
timeCreated: 1627531440 |
撰写
预览
正在加载...
取消
保存
Reference in new issue