Hi, I need to manage a map that is made by 18 x 12 GUITextures; every GUITexture is square (28 x 28 pixels) and has assigned a texture to it.
Sometimes the map is drawn correctly (i.e. the textures reflect the data that stays behing them), but sometimes this doesn’t happen.
It’s like if the system is not able to update every single texture and something stays behind.
I made an “service” button that forces the redraw of the map, and when the same procedure is called a second time, everything is updated ok…
Does anybody have an idea of how everything could be drawn ok the first time ?
As usual, thanks in advance for your help…
I don’t, but I’m also not clear on what exactly it is you’re doing. What do you mean by “the textures reflect the data that stays behind them”? How does that change to indicate things aren’t working?
This is the function:
function drawMap(){
gStartX = 0.209; // start of display area DON't CHANGE !!!
gStartY = 0.855;
deltaX = 0.0402; // distance between tiles DON'T CHANGE !!!
deltaY = 0.0527;
for (var y = 0; y < dspHeight; y++) {
for (var x = 0; x < dspWidth; x++) {
mapSourceIDX = (y+dspOffsetY) * 60 + x + dspOffsetX; // index in source map data
mapDisplayIDX = y * dspWidth + x; // index in display area
mapDspArray[mapDisplayIDX] = Instantiate(baseMapUnit, Vector3(gStartX + x * deltaX, gStartY - y * deltaY,5), Quaternion.identity);
thisTexture = getTextureFromCode(objectCode[mapSourceIDX].zollaType); // returns a number depending on data passed to function
mapDspArray[mapDisplayIDX].guiTexture.texture = gndTextureLib[thisTexture];
}
}
}
(it is part of a larger script); the function is called with the dspOffsetY and dspOffsetX values changed; basically it is used to simulate a scrolling of the map; sometimes all the tiles are drawn ok, but sometimes only part of the tiles have their texture displayed ok: the previous texture is still displayed… it seems that sometimes the system can’t update all the tiles texture… Any idea ?