Update
This commit is contained in:
@@ -7,6 +7,10 @@ namespace UI
|
||||
{
|
||||
private VisualElement _joinView;
|
||||
private VisualElement _createView;
|
||||
|
||||
private float _lastInteractionTime;
|
||||
private bool _isCreateMode = false;
|
||||
private const float AutoReturnDelay = 5f;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
@@ -22,19 +26,50 @@ namespace UI
|
||||
// Create confirm -> Lounge
|
||||
root.Q<Button>("btn-create-confirm")?.RegisterCallback<ClickEvent>(evt => UIManager.Instance.ShowScreen("Lounge"));
|
||||
|
||||
// Toggle password field in Create View
|
||||
// Register Interaction Resetters
|
||||
var textFields = root.Query<TextField>().ToList();
|
||||
foreach (var field in textFields)
|
||||
field.RegisterValueChangedCallback(evt => ResetInteractionTimer());
|
||||
|
||||
var toggles = root.Query<Toggle>().ToList();
|
||||
foreach (var t in toggles)
|
||||
t.RegisterValueChangedCallback(evt => ResetInteractionTimer());
|
||||
|
||||
// Password Toggle Logic
|
||||
var passToggle = root.Q<Toggle>("toggle-password");
|
||||
var passField = root.Q<TextField>("field-password");
|
||||
passToggle?.RegisterValueChangedCallback(evt => {
|
||||
if(passField != null) passField.style.display = evt.newValue ? DisplayStyle.Flex : DisplayStyle.None;
|
||||
});
|
||||
|
||||
ResetInteractionTimer();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (_isCreateMode)
|
||||
{
|
||||
if (Time.time - _lastInteractionTime > AutoReturnDelay)
|
||||
{
|
||||
SetMode(false); // Auto return to Stage 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SetMode(bool isCreate)
|
||||
{
|
||||
_isCreateMode = isCreate;
|
||||
if (_joinView == null) return;
|
||||
|
||||
_joinView.style.display = isCreate ? DisplayStyle.None : DisplayStyle.Flex;
|
||||
_createView.style.display = isCreate ? DisplayStyle.Flex : DisplayStyle.None;
|
||||
|
||||
if (isCreate) ResetInteractionTimer();
|
||||
}
|
||||
|
||||
private void ResetInteractionTimer()
|
||||
{
|
||||
_lastInteractionTime = Time.time;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user