37 lines
691 B
C#
37 lines
691 B
C#
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using TMPro;
|
|
|
|
public class ToggleAIPlayer : MonoBehaviour
|
|
{
|
|
public TMP_Text buttonText;
|
|
|
|
private string currentState = "AI"; // Default state is AI.
|
|
|
|
private void Start()
|
|
{
|
|
UpdateButtonText();
|
|
buttonText.text = "AI";
|
|
}
|
|
|
|
public void OnButtonClick()
|
|
{
|
|
// Toggle between 'AI' and 'Player'.
|
|
if (currentState == "AI")
|
|
{
|
|
currentState = "LOCAL";
|
|
}
|
|
else if(currentState == "LOCAL")
|
|
{
|
|
currentState = "AI";
|
|
}
|
|
|
|
UpdateButtonText();
|
|
}
|
|
|
|
private void UpdateButtonText()
|
|
{
|
|
buttonText.text = currentState;
|
|
}
|
|
}
|