chunk 1: core gameplay scripts scenes runtime assets
This commit is contained in:
36
Assets/Scripts/Character Selection System/ToggleAIPlayer.cs
Normal file
36
Assets/Scripts/Character Selection System/ToggleAIPlayer.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user