revert Add notes handling to TaskButtonManager for UDP commands
This commit is contained in:
2025-11-10 09:38:28 +00:00
parent e3a775ee48
commit 63a2a451c0
2 changed files with 7 additions and 61 deletions

View File

@ -18,17 +18,12 @@ public class TaskButtonManager : MonoBehaviour
private string pendingTimerCommand = null;
private readonly object sceneLock = new object();
private readonly object timerLock = new object();
private readonly object notesLock = new object();
private TaskTimer taskTimer;
private NotesDisplay notesDisplay;
private string pendingNotesText = null;
private void Start()
{
// Find TaskTimer in the scene
taskTimer = FindObjectOfType<TaskTimer>();
// Find NotesDisplay in the scene
notesDisplay = FindObjectOfType<NotesDisplay>();
if (enableUDPControl)
{
@ -65,23 +60,6 @@ public class TaskButtonManager : MonoBehaviour
}
}
// Check for pending notes updates (must be done on main thread)
lock (notesLock)
{
if (!string.IsNullOrEmpty(pendingNotesText))
{
if (notesDisplay != null)
{
notesDisplay.SetNotes(pendingNotesText);
}
else
{
Debug.LogWarning("NotesDisplay not found in scene. Cannot display notes text.");
}
pendingNotesText = null;
}
}
// VR Tasks (Keys 1-4)
if (Input.GetKeyDown(KeyCode.Alpha1) || Input.GetKeyDown(KeyCode.Keypad1))
LoadSceneByName("VR-Task1");
@ -153,12 +131,12 @@ public class TaskButtonManager : MonoBehaviour
if (string.IsNullOrEmpty(message))
return;
// Parse command format: COMMAND:Parameter (Parameter may contain additional colons)
int separatorIndex = message.IndexOf(':');
if (separatorIndex > 0 && separatorIndex < message.Length - 1)
// Parse command format: COMMAND:Parameter
string[] parts = message.Split(':');
if (parts.Length >= 2)
{
string commandType = message.Substring(0, separatorIndex).Trim().ToUpper();
string parameter = message.Substring(separatorIndex + 1); // keep raw to preserve spaces/colons
string commandType = parts[0].Trim().ToUpper();
string parameter = parts[1].Trim();
if (commandType == "SWITCH")
{
@ -178,23 +156,14 @@ public class TaskButtonManager : MonoBehaviour
}
Debug.Log($"Scheduled timer command: {parameter}");
}
else if (commandType == "NOTES")
{
// Notes display command
lock (notesLock)
{
pendingNotesText = parameter;
}
Debug.Log($"Scheduled notes update: {parameter}");
}
else
{
Debug.LogWarning($"Unknown UDP command type: {commandType}. Expected: SWITCH, TIMER or NOTES");
Debug.LogWarning($"Unknown UDP command type: {commandType}. Expected: SWITCH or TIMER");
}
}
else
{
Debug.LogWarning($"Invalid UDP command format: {message}. Expected format: COMMAND:Parameter (e.g., SWITCH:SceneName, TIMER:START or NOTES:Your text)");
Debug.LogWarning($"Invalid UDP command format: {message}. Expected format: COMMAND:Parameter (e.g., SWITCH:SceneName or TIMER:START)");
}
}

View File

@ -1,23 +0,0 @@
using UnityEngine;
using TMPro;
public class NotesDisplay : MonoBehaviour
{
[Header("Notes UI")]
[Tooltip("TextMeshProUGUI field where received notes will be displayed")]
public TextMeshProUGUI notesText;
public void SetNotes(string text)
{
if (notesText != null)
{
notesText.text = text;
}
else
{
Debug.LogWarning("NotesDisplay: notesText is not assigned in the inspector.");
}
}
}