fix emblem taking into account

This commit is contained in:
2025-10-11 01:02:52 +02:00
parent bf4ed2c74f
commit 3545b86b97
2 changed files with 23 additions and 9 deletions

View File

@@ -10,7 +10,7 @@ namespace UI
private TMP_Text _traitName;
[SerializeField]
private TMP_Text _traitEmblemCount;
private TMP_InputField _traitEmblemCount;
public string DisplayName { get; }
@@ -25,10 +25,24 @@ namespace UI
public int GetEmblemCount()
{
int count;
int.TryParse(_traitEmblemCount.text, out count);
if(count != 0)
Debug.Log($"Trait {Trait} has count {count}");
int count = 0;
// Check if the text field has valid content
if (!string.IsNullOrEmpty(_traitEmblemCount.text))
{
// Try to parse the text to an integer
if (int.TryParse(_traitEmblemCount.text, out count))
{
if (count != 0)
Debug.Log($"Trait {Trait} has count {count}");
}
else
{
Debug.LogWarning($"Failed to parse emblem count text '{_traitEmblemCount.text}' for trait {Trait}");
count = 0; // Ensure count is 0 if parsing fails
}
}
return count;
}
}