Exemple #1
0
 private static void SetFill(AutoUnwrapSettings.Fill fill, ProBuilderMesh[] sel)
 {
     UndoUtility.RecordSelection(sel, "Fill UVs");
     for (int i = 0; i < sel.Length; i++)
     {
         foreach (Face q in sel[i].GetSelectedFaces())
         {
             var uv = q.uv;
             uv.fill = fill;
             q.uv    = uv;
         }
     }
 }
        public static void SetFillMode_IsAppliedToMesh([ValueSource("fillModeValues")] AutoUnwrapSettings.Fill fill)
        {
            var shape = ShapeGenerator.CreateShape(ShapeType.Sprite);

            Assume.That(shape, Is.Not.Null);

            try
            {
                var positions = shape.positionsInternal;

                // move it off center so that we can be sure fill/scale doesn't change the offset
                for (int i = 0; i < shape.vertexCount; i++)
                {
                    var p = positions[i];
                    p.x         *= .7f;
                    p.z         *= .4f;
                    p.x         += 1.5f;
                    p.z         += 1.3f;
                    positions[i] = p;
                }

                foreach (var face in shape.faces)
                {
                    AutoUnwrapSettings uv = face.uv;
                    uv.fill = (AutoUnwrapSettings.Fill)fill;
                    face.uv = uv;
                }

                shape.ToMesh();
                shape.Refresh();

                var name = shape.name + "-Fill(" + fill + ")";
                shape.name = name;

#if PB_CREATE_TEST_MESH_TEMPLATES
                TestUtility.SaveAssetTemplate(shape.mesh, name);
#endif

                Mesh template = TestUtility.GetAssetTemplate <Mesh>(name);
                TestUtility.AssertAreEqual(template, shape.mesh, message: name);
            }
            catch (System.Exception e)
            {
                Debug.LogError(e.ToString());
            }
            finally
            {
                UnityEngine.Object.DestroyImmediate(shape.gameObject);
            }
        }