https://docs.unity3d.com/ScriptReference/Transform.Rotate.html
https://docs.unity3d.com/2018.1/Documentation/ScriptReference/Transform.Rotate.html
https://docs.unity3d.com/ScriptReference/Transform.RotateAround.html
transform.Rotate(Vector3.up *Time.deltaTime);
transform.Rotate(0, Time.deltaTime, 0);
transform.Rotate(Vector3.up, Time.deltaTime);
```csharp
using UnityEngine;
//Attach this script to aGameObject to rotate around the target position.
public class Example :MonoBehaviour
{
//Assign aGameObject in the Inspector to rotate around
publicGameObject target;
voidUpdate()
{
// Spin the object around the target at 20 degrees/second.
transform.RotateAround(target.transform.position,Vector3.up, 20 *Time.deltaTime);
}
}
```
void Drag()
{
if (Input.GetMouseButton(1))
{
// while the mouse is held down the cube can be moved around its central axis to provide visual feedback
mouseDelta = Input.mousePosition - previousMousePosition;
mouseDelta *= 0.1f; // reduction of rotation speed
transform.rotation = Quaternion.Euler(mouseDelta.y, -mouseDelta.x, 0) * transform.rotation;
}
else
{
// automatically move to the target position
if (transform.rotation != target.transform.rotation)
{
var step = speed * Time.deltaTime;
transform.rotation = Quaternion.RotateTowards(transform.rotation, target.transform.rotation, step);
}
}
previousMousePosition = Input.mousePosition;
}