Skip to content

Instantly share code, notes, and snippets.

@daniele-quero
Created May 17, 2023 10:25
Show Gist options
  • Save daniele-quero/578e67b3254ef13cb041dff335aafa0a to your computer and use it in GitHub Desktop.
Save daniele-quero/578e67b3254ef13cb041dff335aafa0a to your computer and use it in GitHub Desktop.
public class ToggleCallback : MonoBehaviour
{
public TextMeshProUGUI label;
public List<Toggle> toggles;
void Start()
{
string s = toggles
.Select(t => t)
.Where(t => t.isOn == true)
.First()
.name.Substring(8, 1);
setLabel(s);
}
public void setLabel(string s)
{
if (toggles.All(t => !t.isOn))
s = "";
label.text = "Toggle selected:" + s;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment