更新
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user