public static Mesh GetPrimitiveMesh(PrimitiveType type) { if (!PrimitiveHelper.primitiveMeshes.ContainsKey(type)) { PrimitiveHelper.CreatePrimitiveMesh(type); } return(PrimitiveHelper.primitiveMeshes[type]); }
public static GameObject CreatePrimitive(PrimitiveType type, bool withCollider) { if (withCollider) { return(GameObject.CreatePrimitive(type)); } GameObject gameObject = new GameObject(type.ToString()); MeshFilter meshFilter = gameObject.AddComponent <MeshFilter> (); meshFilter.sharedMesh = PrimitiveHelper.GetPrimitiveMesh(type); gameObject.AddComponent <MeshRenderer> (); return(gameObject); }