How to Change skin of the flappy bird?

Viewed 54

Okay, so i was making a flappy bird game in unity, and i was trying to explore what i can do to make the game more responsive and decided to make the bird change color according to the player. I watched tutorials and did some work and added buttons, added Sprite Library, Made Sprite library asset and made a skin changer script too. But when i press button it did change in the inspector panel but didn't in the game.

using System.Collections.Generic;
using UnityEngine;
using UnityEngine.U2D.Animation;

public class SkinChanger : MonoBehaviour
{

    public SpriteLibraryAsset[] sprite;

    public void setRed()
    {
        changeSkin(sprite[1]);
    }
    public void setBlue()
    {
        changeSkin(sprite[2]);
    }
    public void setYellow()
    {
        changeSkin(sprite[0]);
    }

    public void changeSkin(SpriteLibraryAsset skin)
    {
        GetComponent<SpriteLibrary>().spriteLibraryAsset = skin;
    }

}

It Doesn't work when we are playing the game, but does when we change it manually from the Sprite library of the player.

Can you please suggest what should i do??

Flappy Bird Problem

0 Answers
Related