using UnityEngine;
using [Link];
public class ToggleSwitch : MonoBehaviour
{
public Animator modelAnimator;
void Start()
{
// Make sure to assign the Animator component to the public variable in the
Inspector
if (modelAnimator == null)
{
[Link]("Model Animator not assigned!");
}
}
public void PlayIdleAnimation()
{
[Link]("Idle"); // Replace "Idle" with the name of your idle
animation
}
public void PlayWalkAnimation()
{
[Link]("Walk"); // Replace "Walk" with the name of your walk
animation
}
}
private bool isOn = false;
private Text buttonText;
void Start()
{
// Assuming the Text component is on the same GameObject as the Button
buttonText = GetComponentInChildren<Text>();
UpdateButtonText();
}
public void OnButtonClick()
{
isOn = !isOn;
UpdateButtonText();
[Link]();
// Add any additional actions you want to perform when the switch is
toggled
}
private void UpdateButtonText()
{
[Link] = isOn ? "ON" : "OFF";
}
}