public static NPVoxModel NewInstance(NPVoxModel parent, NPVoxCoord size, NPVoxModel reuse = null) { NPVoxModel voxModel = null; if (reuse == null || reuse.GetType() != parent.GetType()) { if (reuse != null) { Object.DestroyImmediate(reuse); } voxModel = (NPVoxModel)parent.GetType() .GetMethod("NewInstance", new System.Type[] { typeof(NPVoxCoord), typeof(NPVoxModel) }) .Invoke(null, new object[] { size, reuse }); } else { voxModel = reuse; } voxModel.name = "Model"; voxModel.Initialize(size); return(voxModel); }