|
(I am currently using C#) I have a set of objects (cubes in this case) that I am loading into an array to perform all sorts of functions on. My issue is that I want to be able to delete the cubes, replace them (instance their prefabs into the scene) wherever I want them and then continue running my functions with the new cubes. I've probably overlooked a simple solution (as is commonly the case with these things). So, what I want to know is how to have it so the scripts don't suddenly run aground when they have no cubes to reference inside the arrays, and how to re-build the content of the arrays once the cubes have been replaced. Can I disable a script and then restart it, re-finding the new cubes? (just as an addition I am loading the cubes into the array using tags) cubeArray = GameObject.FindGameObjectsWithTag ("cube");
(comments are locked)
|
|
Use a list, and remove each cubes you're destroying, add those you create. So basically I have to change all my arrays into lists? And change all the methods of doing things into the ones that relate to lists... and... dayum.
Jun 27 '12 at 04:16 PM
Flufflesthepancake
Whenever a data structure's size is going to change, go for the list. If you know it will remain constant, arrays are perfectly fine.
Jun 27 '12 at 04:38 PM
Berenger
(comments are locked)
|
