show icon on press key V
This commit is contained in:
22
Class1.cs
22
Class1.cs
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user