Storing a Class in a variable

Ive been having issues with this for quite a bit now and cant find anything on the wiki / answers about this . Basically, I have a Block class for my voxel engine, each voxel has an individual instance of the Block class, this class basically stores the main aspects of the block, the ID , the texture data and stuff, but I wanted to implement a feature that allowed me to have custom classes for each block so that I can make them store custom variables and also make them have features individually.

I am having trouble thinking of a way to fill an array of 32x32x32 values with different block classes, I thought of having all the classes as blocks and then having a variable hold the secondary " feature " class of the block , this is how I do it so far :

// I was not sure how to store it so I did this :

public object customClass;

// I then had a switch to manage which class to instance 


			case 0:
			customClass= new BlockEngine(this,1.0f);

I just dont know how I would access the class from another script because I cannot do :


because it does not give me the option to access it through that. If anybody could show me a way to store a kind of changeable class type variable, I would be very grateful!


Ok so, I think I actually figured a way around this, however it is not the most efficient way. I did this :

public BlockFeature customClass;

then I initialized it using a case system , like before :

	case 0:
			customClass= new BlockEng();

Then I had a " somewhat clever " way around the fact that derived classes work through their base class, so instead, I did this :

public class BlockFeature {
	public virtual void doStuff(string a)

Made a basic class with a virtual void function, which was overridden by the other class :

class BlockEng : BlockFeature{
	public override void doStuff(string a){
		case "getThrust":
	public void getThrust () {
		Debug.Log ("THRUST!");

which allows me to call functions in this derived class through the main class allowing me to technically store these classes in a single variable that is different for every block!

If anybody has a more efficient way, please, tell me because this way is in no way efficient, it just works for now!