38 lines
965 B
C#
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.");
|
|
}
|
|
|
|
|
|
}
|
|
}
|