AK056/Assets/GameLogic/Origin/ui/button/AutoRotationButton.cs

57 lines
1.2 KiB
C#

using EasyInject.Attributes;
using TMPro;
using UnityEngine;
using UnityEngine.Playables;
using UnityEngine.UI;
/// <summary>
/// 自动旋转按钮
/// </summary>
[GameObjectBean]
public class AutoRotationButton : MonoBehaviour
{
public PlayableDirector playable;
private Button button;
private TMP_Text text;
private bool isRotation = true;
public LayerMask layerMask;
void Start()
{
button = GetComponent<Button>();
text = button.transform.GetComponentInChildren<TMP_Text>();
button.onClick.AddListener(ClickRotationBtn);
}
public void ClickRotationBtn()
{
isRotation = !isRotation;
Camera.main.cullingMask = layerMask;
if (isRotation)
{
text.text = "关闭旋转";
playable.Play();
}
else
{
text.text = "自旋转";
playable.Stop();
}
}
public void ClickRotationBtn( bool rotation)
{
isRotation = rotation;
Camera.main.cullingMask = layerMask;
if (isRotation)
{
text.text = "关闭旋转";
playable.Play();
}
else
{
text.text = "自旋转";
playable.Stop();
}
}
}