Files
vr-configurator/vr-configurator/Assets/Scripts/UI/PortAssigner.cs
2025-05-10 11:50:24 +02:00

38 lines
965 B
C#

using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class PortAssigner : MonoBehaviour
{
public ChildModelSelector options;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
Toggle toggle = GetComponent<Toggle>();
if (toggle != null)
{
toggle.onValueChanged.AddListener(OnToggleValueChanged);
}
else
{
Debug.LogError("Toggle component not found on GameObject.");
}
}
private void OnToggleValueChanged(bool isOn)
{
var textmesh = GetComponentInChildren<TextMeshProUGUI>(true);
if (textmesh != null)
{
string port = textmesh.text;
options.setPort(port);
options.AssignButtons();
}
else
{
Debug.LogError("TextMeshProUGUI component not found in children.");
}
}
}