show icon on press key V

This commit is contained in:
Jose Luis Montañes Ojados
2026-01-06 05:50:51 +01:00
parent 3a2fe72742
commit d80451ab55
8 changed files with 27 additions and 7 deletions

View File

@@ -183,6 +183,18 @@ namespace StrategicMapPlus
private Image iconImage;
private TextMeshProUGUI debugText;
private bool isInitialized = false;
private bool hasContent = false;
void Update()
{
if (!isInitialized || displayObj == null) return;
bool shouldShow = hasContent && Input.GetKey(KeyCode.V);
if (displayObj.activeSelf != shouldShow)
{
displayObj.SetActive(shouldShow);
}
}
public void Initialize()
{
@@ -224,6 +236,9 @@ namespace StrategicMapPlus
// CRUCIAL: Ponemos el icono al final de la lista de hijos para que se pinte ENCIMA
displayObj.transform.SetAsLastSibling();
// Inicialmente oculto
displayObj.SetActive(false);
isInitialized = true;
}
catch (System.Exception e)
@@ -236,6 +251,7 @@ namespace StrategicMapPlus
public void Hide()
{
hasContent = false;
if (displayObj != null && displayObj.activeSelf) displayObj.SetActive(false);
}
@@ -247,13 +263,12 @@ namespace StrategicMapPlus
// Aseguramos orden de dibujado (Encima de todo)
displayObj.transform.SetAsLastSibling();
if (!displayObj.activeSelf) displayObj.SetActive(true);
if (s != null)
{
iconImage.sprite = s;
iconImage.enabled = true;
if (debugText != null) debugText.text = "";
hasContent = true;
}
}
@@ -264,10 +279,9 @@ namespace StrategicMapPlus
displayObj.transform.SetAsLastSibling();
if (!displayObj.activeSelf) displayObj.SetActive(true);
if (iconImage != null) iconImage.enabled = false;
if (debugText != null) debugText.text = t;
hasContent = true;
}
}
}