Switch between 2 UI Images?

I have a code that’s supposed to make one UI Image appear when the 1 key is pressed, and a different one appear when the 2 key is pressed. Here’s what I have…

var RightTexture :Canvas;
var LeftTexture :Canvas;

function Start () {
    RightTexture.enabled = true;
    LeftTexture.enabled = false;
}

function Update () {
    if (Input.GetKeyDown ("1"))
        if( RightTexture.enabled == true){
         LeftTexture.enabled = true;
         RightTexture.enabled = false;
    }
    if (Input.GetKeyDown ("2"))
       if (LeftTexture.enabled == true){
        RightTexture.enabled = true;
        LeftTexture.enabled = false;
       
       
         }
    }

But for some reason, it doesn’t work right. How can I fix it to do what I want?

I have just started to use Unity UI but I believe a Canvas has no graphic qualities like a sprite. Why aren’t you using Sprite Renderer?

Oh sorry. I accidentally deleted my script so I copied on similar to it and tried to make it again. I guess I forgot to change that. It still doesn’t work right though. Here’s the actual version…

var RightTexture :UnityEngine.UI.Image;
var LeftTexture :UnityEngine.UI.Image;

function Start () {
    RightTexture.enabled = true;
    LeftTexture.enabled = false;
}

function Update () {
    if (Input.GetKeyDown ("1"))
        if( RightTexture.enabled == true){
         LeftTexture.enabled = true;
         RightTexture.enabled = false;
    }
    if (Input.GetKeyDown ("1"))
       if (LeftTexture.enabled == true){
        RightTexture.enabled = true;
        LeftTexture.enabled = false;
       
       
         }
    }

Thoroughly examine your script and think about its logic. Reading aloud can really help.

If key 1 is down and right texture enabled is true, then enable the left texture and disable the right texture.
If key 1 is down and left texture enabled is true, then enable the right texture and disable the left texture.

See the flaw? It instantly resets itself.

Sorry, I deleted it, rewrote it, and forgot to change the input from a 1 to a 2. It ended u working, so cool. But I want to try something. How would I make it so that the UI Image that equals will true will only appear for 2 seconds?