Ok so this happened today within about a couple of hours prior to this post. I have a sprite that is kept invisible until an effect makes it visible (NGUI 11). When the game runs all seems to be well (NGUI 12). BUt you press the button with a shield and S on it and suddenly...
the object may appear for a split second and then immediately disappear and gets detroyed (NGUI 13). My question is why is this happening and why is this the only sprite affected.
Unity: 4.1.2f
2Dtk: 1.92 + Patch 1
Before you go accusing me of destroying. this is the only piece of code "I wrote" that touches the sprite. Please note that sprite is the Shield Sprite, and icon is the Button Sprite.
The weird thing is this just happened randomly.
public void clickedFA ()
{
// tracker.AddProgressToAchievement ("Shielded", 1.0f);
// StoreInventory.TakeItem (itemId, 1);
// balance = StoreInventory.GetItemBalance (itemId);
balance--;
textMesh.text = balance.ToString ();
textMesh.Commit ();
icon.color = Color.gray;
cooldownActive = !cooldownActive;
Invoke("ResetIcon", 5); // cooldown in 5 seconds.
ActivateShield();
}
private void ActivateShield() {
sprite.gameObject.SetActive(true);
Invoke("DectivateShield", 3); // last 3 seconds
}
private void DectivateShield() {
sprite.gameObject.SetActive(false);
}