- Home /
Deletion Sequence issue
Hi, I have some problem with this code
public void FormTileIslandArray()
{
ClearIsland();
for( CardAtt.COLORS color = CardAtt.COLORS.RED; color< CardAtt.COLORS.LENGTH; color++ )
{
for( CardAtt.NUMBERS number = CardAtt.NUMBERS.ONE; number< CardAtt.NUMBERS.LENGTH; number++ )
{
SpawnTileIsland( number, color );
}
}
}
public void ClearIsland()
{
foreach( GameObject tileIsland in GameObject.FindGameObjectsWithTag("tileIsland") )
{
DestroyObject(tileIsland);
}
}
The code was suppose to delete away all of the existing TileIsland Gameobjects before going into a Spawn sequence.
However, all of the TileIsland didn't get deleted before going into spawn sequence, so it caused unwanted errors.
I tried Coroutine, and it didn't helped.
TileIsland is only meant to store list of tiles data. The reason that I made TileIslands into GameObjects, was so that I can check their data in the inspector. If I made Tile Island into an ArrayList instead, I don't know how to check what's inside.
Can anyone suggest me an alternative way to solve this? THX in advance.
Answer by CHPedersen · Aug 26, 2012 at 06:36 PM
I think this happens because Destroy doesn't destroy the objects right away, it only schedules them for destruction which occurs after the update loop, see link for more information.
Try with DestroyImmediate and see if that results in the desired behavior.
Answer by Levantez · Aug 26, 2012 at 06:39 PM
THX Christian, I just checked around and found that I can get the data to appear in the inspector by using using System.Collections.Generic; [System.Serializable] It worked better for me this way now. None the less, Thank you for your reply
Your answer
Follow this Question
Related Questions
How do you Place/Spawn a GameObject or Prefab in front of Player 2 Answers
Spawn Script 1 Answer
How can I change the index of an array object? 2 Answers
Makes object appear and disappear after a few seconds 3 Answers
object spawn on trigger 1 Answer