Run down of what I am doing:
Using scene view in editor to modify marching cubes set.
My problem is:
the values in a List i am using for the marching cubes grid are not being retained in the scene. So when I save/close then reload the List is empty and null.
My List looks something like this…
public class RoomCubes : MonoBehaviour
{
public List<List<List<voxel>>> vox;
}
public class voxel{
public bool check;
public bool mark;
}
Unfortunately lists of lists are not serialized (and therefore not saved) by Unity.
A hacky, but working solution is to define a class for each dimension of your array.
E.g.
public class RoomCubes : MonoBehaviour
{
[SerializeField]
List<VoxelD1> voxels;
[System.Serializable]
class VoxelD1
{
List<VoxelD2> voxels;
}
[System.Serializable]
class VoxelD2
{
List<Voxel> voxels;
}
[System.Serializable]
public class Voxel
{
public bool check;
public bool mark;
}
}
Then, to get the element at 1,1,1
voxels[1].voxels[1].voxels[1]
Which is pretty ugly. You could write a method
List<List<List<voxel>>> generateListRepresentation();
to generate your previous format for ease of use.