I have the following scripts:
void Start()
{
thisTurret = this.gameObject;
//InvokeRepeating("UpdateTarget", 0f, 0.5f);
buildManager = BuildManager.instance;
}
private void OnMouseDown()
{
Debug.Log("This turret is: " + thisTurret.ToString());
if (EventSystem.current.IsPointerOverGameObject())
{
return;
}
if (thisTurret != null)
{
buildManager.SelectTurret(this);
}
}
and
public void SelectTurret(Turret turret)
{
if(selectedTurret == turret)
{
//Debug.Log("Selected turret is: " + selectedTurret.ToString());
DeselectTurret(selectedTurret);
return;
}
selectedTurret = turret;
//Debug.Log("Selected turret here is: " + selectedTurret.ToString());
//Debug.Log("Pasted turret here is: " + turret.ToString());
if (oldSelectedTurret == null)
{
oldSelectedTurret = selectedTurret;
}
//Debug.Log("Selected turret is: " + selectedTurret.ToString());
if (oldSelectedTurret != selectedTurret)
{
turretUI.Hide(oldSelectedTurret);
//Debug.Log("Old in if Selected turret is: " + oldSelectedTurret.ToString());
oldSelectedTurret = selectedTurret;
}
Debug.Log("Current Selected turret is: " + selectedTurret.ToString());
turretToBuild = null;
turretUI.SetTarget(selectedTurret);
}
public void DeselectTurret(Turret turret)
{
if(turret != null)
{
//Debug.Log("Turret to deselect is: " + turret.ToString());
turretUI.Hide(turret);
selectedTurret = null;
}
else
{
//Debug.Log("Turret to deselect is null!");
}
}
As the title say the OnMouseDown() executes only once then stop working and is not the console collapse