I'm only just getting into custom classes... So I'm creating a class called Chunk:
class Chunk
{
public static var cornerPos = new Vector3[3];
function Chunk(){} // Constructor
}
// Create an array of chunks
var chunks = new Chunk[10];
If I remake the chunks array - for instance to resize it, add or delete chunks - will the actual instances of the Chunk class still remain? As I understand it, if I use the Instantiate command with a variable...
var clone = Instantiate(chunkClone, Vector3(0,0,0), Quaternion.identity);
... if I change that variable (or it's declared in a function and so disappears at the end of the function), the instantiated GameObject still remains in the hierachy as the variable was just a reference to it. Is it the same thing with my custom class?
For example, I might use the following to resize the array:
var chunksTemp = chunks;
chunks = new Chunk[9];
for (a=0;a<9;a++) {
chunks[a] = chunksTemp[a];
}
Will there now be 19 instances of the Chunk class in memory, 10 of them just floating in the ether, or do those 10 instances get somehow cleared away when I redeclare the array? And if the initial 10 instances created do stay behind, how do I destroy them manually?
Great, just what I wanted to hear!
– quoxel