I don't think you guys understood my problem, here I go again:
Let's say I have background sprite covering the whole screen (it's actually not 1 sprite, but for simplification, lets consider it only 1)
I want to delete that background sprite and inmediatly create a new background sprite which also covers the whole screen.
for that purpose i do:
Destroy( oldBackground );
GameObject newBackground= NGUITools.AddChild(someParent, myPrefab);
myPanel.Refresh();
the result?
frame n: the background is gone
frame n+1: new background appears
so I see a black background when swapping out background sprites this way.
my workaround?
IEnumerator DeleteBGOnNextFrame() {
yield return null; // skip one frame
Destroy( oldBackground );
}
then I call:
// create new background NOW
GameObject newBackground= NGUITools.AddChild(someParent, myPrefab);
// delete existing background on Next Frame:
StartCoroutine("DeleteBGOnNextFrame");
this way I avoid the black background between deletion and creation.
instead of having to delay the deletion one fame, can't I force the creation of the sprite inmediatly?
I thought UIPanel.Refresh is exactly for that... but re-read now my first original post and see what happens... same thing.