コード例 #1
0
        public static Sprite GetTexture(string name)
        {
            foreach (LSprite s in sprites)
            {
                if (s.name == name)
                {
                    return(s.sprite);
                }
            }

            LSprite ls = new LSprite();

            ls.name = name;
            Texture2D t = (Texture2D)Resources.Load("Textures/" + name);

            if (t == null)
            {
                UnityEngine.Debug.Log("Error could not load sprite : " + name);
            }
            ls.sprite = Sprite.Create(t,
                                      new Rect(0, 0, t.width, t.height), new Vector2(0.5f, 0.5f));

            sprites.Add(ls);
            return(ls.sprite);
        }
コード例 #2
0
        public static Sprite GetSprite(string name)
        {
            foreach (LSprite s in sprites)
            {
                if (s.name == name)
                {
                    return(s.sprite);
                }
            }

            LSprite ls = new LSprite();

            ls.name = name;
            Sprite t = (Sprite)Resources.Load("Textures/" + name);

            if (t == null)
            {
                UnityEngine.Debug.Log("COULD NOT LOAD SPRITE  " + name);
            }
            ls.sprite = t;
            sprites.Add(ls);
            return(ls.sprite);
        }