Exemplo n.º 1
0
        public static SpriteObject ImageFileToSprite(string filename, string spriteName, bool isEmbeddedResource = false)
        {
            Texture2D texture = ImageFileToTexture(filename, isEmbeddedResource);

            if (texture == null)
            {
                return(null);
            }

            GameObject spriteGameObject = tk2dSprite.CreateFromTexture(
                texture,
                tk2dSpriteCollectionSize.ForResolution(GameCamera.SCREEN_DEFAULT_HEIGHT_HALF, GameCamera.SCREEN_DEFAULT_WIDTH, GameCamera.SCREEN_DEFAULT_HEIGHT),
                new Rect(0f, 0f, texture.width, texture.height),
                Vector2.zero);

            tk2dSprite sprite = spriteGameObject.GetComponent <tk2dSprite>();

            sprite.CurrentSprite.name = spriteName;

            return(DisplayUtils.CreateSpriteObject(sprite.Collection, spriteName));
        }