public void SetShape(ShapeType type) { if (shapeType == type) { return; } bool cube = type == ShapeType.CUBE; var faces = GetComponentsInChildren <PickableFace>(); foreach (var face in faces) { face.GetComponent <BoxCollider>().enabled = cube; } isInteractable = !cube; shapeType = type; var shape = ModificationSystem.get().getShape(type); gameObject.GetComponent <MeshFilter>().mesh = shape.mesh; gameObject.GetComponent <MeshCollider>().sharedMesh = shape.mesh; }
private void SetMaterialAndColor(MaterialType materialType, ColorType colorType) { ColorAndMaterialType?type = null; switch (materialType) { case MaterialType.ABSTRACT: switch (colorType) { case ColorType.BLUE: type = ColorAndMaterialType.ABSTRACT_BLUE; break; case ColorType.GREY: type = ColorAndMaterialType.ABSTRACT_GREY; break; case ColorType.RED: type = ColorAndMaterialType.ABSTRACT_RED; break; case ColorType.YELLOW: type = ColorAndMaterialType.ABSTRACT_YELLOW; break; } break; case MaterialType.CHECKERED: switch (colorType) { case ColorType.BLUE: type = ColorAndMaterialType.CHECKERED_BLUE; break; case ColorType.GREY: type = ColorAndMaterialType.CHECKERED_GREY; break; case ColorType.RED: type = ColorAndMaterialType.CHECKERED_RED; break; case ColorType.YELLOW: type = ColorAndMaterialType.CHECKERED_YELLOW; break; } break; case MaterialType.MATTE: switch (colorType) { case ColorType.BLUE: type = ColorAndMaterialType.MATTE_BLUE; break; case ColorType.GREY: type = ColorAndMaterialType.MATTE_GREY; break; case ColorType.RED: type = ColorAndMaterialType.MATTE_RED; break; case ColorType.YELLOW: type = ColorAndMaterialType.MATTE_YELLOW; break; } break; case MaterialType.METAL: switch (colorType) { case ColorType.BLUE: type = ColorAndMaterialType.METAL_BLUE; break; case ColorType.GREY: type = ColorAndMaterialType.METAL_GREY; break; case ColorType.RED: type = ColorAndMaterialType.METAL_RED; break; case ColorType.YELLOW: type = ColorAndMaterialType.METAL_YELLOW; break; } break; } if (type == null) { throw new System.Exception("missing combination for: " + colorType + ", " + materialType); } this.colorType = colorType; this.materialType = materialType; GetComponent <MeshRenderer>().material = ModificationSystem.get().getMaterial(type.Value).material; }