/** * \brief Creates a new #pb_Object using passed vertices to construct geometry. * Typically you would not call this directly, as the #ProBuilder class contains * a wrapper for this purpose. In fact, I'm not sure why this is public... * @param vertices A vertex array (Vector3[]) containing the points to be used in * the construction of the #pb_Object. Vertices must be wound in counter-clockise * order. Triangles will be wound in vertex groups of 4, with the winding order * 0,1,2 1,3,2. Ex: * \code{.cs} * // Creates a pb_Object plane * pb_Object.CreateInstanceWithPoints(new Vector3[4]{ * new Vector3(-.5f, -.5f, 0f), * new Vector3(.5f, -.5f, 0f), * new Vector3(-.5f, .5f, 0f), * new Vector3(.5f, .5f, 0f) * }); * * \endcode * \returns The resulting #pb_Object. */ public static pb_Object CreateInstanceWithPoints(Vector3[] vertices) { if (vertices.Length % 4 != 0) { Debug.LogWarning("Invalid Geometry. Make sure vertices in are pairs of 4 (faces)."); return(null); } GameObject _gameObject = new GameObject(); pb_Object pb_obj = _gameObject.AddComponent <pb_Object>(); pb_obj.SetName("Object"); pb_obj.GeometryWithPoints(vertices); pb_obj.entity.SetEntity(EntityType.Detail); return(pb_obj); }