Exemplo n.º 1
0
 static public int GetSprite(IntPtr l)
 {
     try {
         LBoot.SpriteAsset self = (LBoot.SpriteAsset)checkSelf(l);
         System.String     a1;
         checkType(l, 2, out a1);
         var ret = self.GetSprite(a1);
         pushValue(l, ret);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Exemplo n.º 2
0
        public Sprite GetSprite(string spriteName)
        {
            string assetPath = null;

            sprites.TryGetValue(spriteName, out assetPath);
            if (assetPath == null)
            {
                return(null);
            }

            assetPath = "assets/" + assetPath + ".asset";
            assetPath = assetPath.ToLower();
            SpriteAsset spriteAsset = null;

#if UNITY_EDITOR
            spriteAsset = UnityEditor.AssetDatabase.LoadAssetAtPath <SpriteAsset>(assetPath);
#else
            string bundlePath = null;

            images.TryGetValue(assetPath, out bundlePath);

            if (bundlePath != null)
            {
                var assetBundle = BundleHelper.Load(bundlePath, -1);
                if (assetBundle != null)
                {
                    spriteAsset = assetBundle.LoadAsset <SpriteAsset>(assetPath);
                }
            }
#endif
            if (spriteAsset != null)
            {
                return(spriteAsset.GetSprite(spriteName));
            }

            return(null);
        }