39 lines
1.0 KiB
C#
39 lines
1.0 KiB
C#
using UnityEngine;
|
|
|
|
namespace GraphicsCat
|
|
{
|
|
public class AutoRotate : MonoBehaviour, IMGUIDockable
|
|
{
|
|
public bool autoRotateEnabled = true;
|
|
public Vector3 autoRotateSpeed = new Vector3(0, 5, 0);
|
|
public bool guiEnabled = false;
|
|
|
|
Transform m_Transform;
|
|
|
|
void Start()
|
|
{
|
|
m_Transform = transform;
|
|
if (guiEnabled)
|
|
IMGUIDock.topRight.DockGUI(this);
|
|
}
|
|
|
|
void Update()
|
|
{
|
|
if (autoRotateEnabled)
|
|
{
|
|
m_Transform.Rotate(autoRotateSpeed * Time.deltaTime, Space.Self);
|
|
// m_Transform.localEulerAngles = m_Transform.localEulerAngles + autoRotateSpeed * Time.deltaTime;
|
|
}
|
|
}
|
|
|
|
public void OnDockGUI()
|
|
{
|
|
GUILayout.BeginHorizontal();
|
|
if (GUILayout.Button($"Auto Rotate {(autoRotateEnabled ? "O" : "X")}"))
|
|
autoRotateEnabled = !autoRotateEnabled;
|
|
GUILayout.EndHorizontal();
|
|
}
|
|
}
|
|
}
|
|
|