Tanoda
LeapSpriteFeature.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 System;
10using UnityEngine;
11using UnityEngine.Rendering;
12#if UNITY_EDITOR
13using UnityEditor;
14using UnityEditor.Sprites;
15#endif
17
19
20 [LeapGraphicTag("Sprite", 20)]
21 [Serializable]
22 public class LeapSpriteFeature : LeapGraphicFeature<LeapSpriteData> {
23
24 [Delayed]
26 public string propertyName = "_MainTex";
27
29 public UVChannelFlags channel = UVChannelFlags.UV0;
30
31#if UNITY_EDITOR
32 public bool AreAllSpritesPacked() {
33 foreach (var dataObj in featureData) {
34 if (dataObj.sprite == null) continue;
35
36 if (!dataObj.sprite.packed) {
37 return false;
38 }
39 }
40 return true;
41 }
42
43 public bool AreAllSpritesOnSameTexture() {
44 Texture2D mainTex = null;
45 foreach (var dataObj in featureData) {
46 if (dataObj.sprite == null) continue;
47
48 string atlasName;
49 Texture2D atlasTex;
50 Packer.GetAtlasDataForSprite(dataObj.sprite, out atlasName, out atlasTex);
51
52 if (mainTex == null) {
53 mainTex = atlasTex;
54 } else {
55 if (mainTex != atlasTex) {
56 return false;
57 }
58 }
59 }
60
61 return true;
62 }
63#endif
64 }
65}