mirror of
https://github.com/BotChain-Robots/ui.git
synced 2026-07-08 15:07:22 +02:00
switch from Unity version control to git
This commit is contained in:
31
Assets/DragRotate.cs
Normal file
31
Assets/DragRotate.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class DragRotate : MonoBehaviour
|
||||
{
|
||||
public float rotationSpeed = 100f;
|
||||
private bool isSelected = false;
|
||||
|
||||
void OnMouseDown()
|
||||
{
|
||||
isSelected = true;
|
||||
}
|
||||
|
||||
void OnMouseUp()
|
||||
{
|
||||
isSelected = false;
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (Input.GetMouseButton(0) && isSelected)
|
||||
{
|
||||
float mouseX = Input.GetAxis("Mouse X");
|
||||
float mouseY = Input.GetAxis("Mouse Y");
|
||||
|
||||
// Horizontal (Y axis)
|
||||
transform.Rotate(Vector3.up, -mouseX * rotationSpeed * Time.deltaTime, Space.World);
|
||||
// Vertical (X axis)
|
||||
transform.Rotate(Vector3.right, mouseY * rotationSpeed * Time.deltaTime, Space.World);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user