Ejemplo n.º 1
0
        internal static float ConvertCategoryLabelHashToSpriteKey(SpriteLibrary library, int categoryHash, int labelHash)
        {
            if (library != null)
            {
                foreach (var category in library.categoryNames)
                {
                    if (categoryHash == SpriteLibraryAsset.GetStringHash(category))
                    {
                        var entries = library.GetEntryNames(category);
                        if (entries != null)
                        {
                            foreach (var entry in entries)
                            {
                                if (labelHash == SpriteLibraryAsset.GetStringHash(entry))
                                {
                                    var spriteKey = SpriteLibrary.GetHashForCategoryAndEntry(category, entry);
                                    return(ConvertIntToFloat(spriteKey));
                                }
                            }
                        }
                    }
                }
            }

            return(0);
        }
        void SetSprite(Sprite sprite)
        {
            var sl = spriteLibrary;

            if (sl != null && sprite != null)
            {
                foreach (var cat in sl.categoryNames)
                {
                    var entries = sl.GetEntryNames(cat);
                    foreach (var ent in entries)
                    {
                        if (sl.GetSprite(cat, ent) == sprite)
                        {
                            spriteKeyInt = SpriteLibrary.GetHashForCategoryAndEntry(cat, ent);
                            return;
                        }
                    }
                }
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Set the Category and label to use
 /// </summary>
 /// <param name="category">Category to use</param>
 /// <param name="label">Label to use</param>
 public void SetCategoryAndLabel(string category, string label)
 {
     spriteKeyInt           = SpriteLibrary.GetHashForCategoryAndEntry(category, label);
     m_PreviousSpriteKeyInt = spriteKeyInt;
     ResolveSpriteToSpriteRenderer();
 }