Tanoda
LeapSpriteGraphic.cs
Go to the documentation of this file.
1/******************************************************************************
2 * Copyright (C) Ultraleap, Inc. 2011-2020. *
3 * *
4 * Use subject to the terms of the Apache License 2.0 available at *
5 * http://www.apache.org/licenses/LICENSE-2.0, or another agreement *
6 * between Ultraleap and you, your company or other organization. *
7 ******************************************************************************/
8
9using UnityEngine;
10using Leap.Unity.Query;
11
13
19 [DisallowMultipleComponent]
21
22 public override void RefreshMeshData() {
23 var spriteData = this.Sprite();
24 if (spriteData == null || spriteData.sprite == null) {
25 mesh = null;
27 return;
28 }
29
30 var sprite = spriteData.sprite;
31
32 if (mesh == null) {
33 mesh = new Mesh();
34 }
35
36 mesh.name = "Sprite Mesh";
37 mesh.hideFlags = HideFlags.HideAndDontSave;
38
39 mesh.Clear(keepVertexLayout: false);
40 mesh.vertices = sprite.vertices.Query().Select(v => (Vector3)v).ToArray();
41 mesh.triangles = sprite.triangles.Query().Select(i => (int)i).ToArray();
42
43 Vector2[] uvs;
44 if (SpriteAtlasUtil.TryGetAtlasedUvs(sprite, out uvs)) {
45 mesh.uv = uvs;
46 }
47
48 mesh.RecalculateBounds();
49
50 //We are using atlas uvs, so no remapping allowed!
52 }
53 }
54}
This class is a base class for all graphics that can be represented by a mesh object.
Mesh mesh
Returns the mesh that represents this graphic. It can have any topology, any number of uv channels,...
UVChannelFlags remappableChannels
Returns an enum mask that represents the union of all channels that are allowed to be remapped for th...
The Sprite Graphic is a type of procedural mesh graphic that allows you to directly use sprite object...
override void RefreshMeshData()
When this method is called, the mesh property and the remappableChannels property must be assigned to...