gpt-4.1-mini-2025-04-14· openai
from WildChat-4.8M
make me a 2d ui rotation script for smooth slow rotation in a circle, provide a speed…
Private research annotation
Sign in to add a private research label or note.
- User
make me a 2d ui rotation script for smooth slow rotation in a circle, provide a speed property and a reverse bool
- Assistant
Certainly! Below is a simple Unity C# script that smoothly rotates a 2D UI element around its center in a circle. It includes a
speedproperty to control the rotation speed and areverseboolean to control the direction of rotation.Attach this script to your UI GameObject (with a RectTransform):
csharpusing UnityEngine; public class SmoothUIRotation : MonoBehaviour { [Tooltip("Rotation speed in degrees per second.")] public float speed = 30f; [Tooltip("If true, rotates in the opposite direction.")] public bool reverse = false; void Update() { float direction = reverse ? -1f : 1f; // Rotate around Z axis for 2D UI rotation transform.Rotate(0f, 0f, direction * speed * Time.deltaTime); } }