public override void Build()
{
meshUvs = new Vector2[16];
meshVertices = new Vector3[16];
meshColors = new Color[16];
SetIndices();
SetGeometry(meshVertices, meshUvs);
SetColors(meshColors);
if (mesh == null)
{
mesh = new Mesh();
mesh.hideFlags = HideFlags.DontSave;
}
else
{
mesh.Clear();
}
mesh.vertices = meshVertices;
mesh.colors = meshColors;
mesh.uv = meshUvs;
mesh.triangles = meshIndices;
mesh.RecalculateBounds();
GetComponent<MeshFilter>().mesh = mesh;
UpdateCollider();
UpdateMaterial();
}
static void DoCreateSlicedSpriteObject() { tk2dSpriteGuiUtility.GetSpriteCollectionAndCreate((sprColl) => { GameObject go = tk2dEditorUtility.CreateGameObjectInScene("Sliced Sprite"); tk2dSlicedSprite sprite = go.AddComponent <tk2dSlicedSprite>(); sprite.SetSprite(sprColl, sprColl.FirstValidDefinitionIndex); sprite.Build(); Selection.activeGameObject = go; Undo.RegisterCreatedObjectUndo(go, "Create Sliced Sprite"); }); }