Selection Screen

Hello , ive made car selection screen, i can switch next and back working great.
i have coins.
i made buy button to appear on specific index of car . working nice

on button click i enable map so player playes that map, but when i turn to next car, map remains enabled. how can i arrange this, i cant go to logic how it works

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ManqanisYidva : MonoBehaviour
{
    DriftManager manager;
    // Update is called once per frame
    void Start()
    {
        manager = GameObject.FindObjectOfType<DriftManager>();
    }

    public GameObject Map;

    //M3
    public GameObject m3Button;

    bool nayidiaBMW=false;

    public void Update()
    {
        if (nayidiaBMW == false)
        {         
         
            Map.SetActive(false);
           
        }
        else if(nayidiaBMW == true)
        {
            Map.SetActive(true);
        }
       
    }

    public void M3YIDVA()
    {
        if((manager.totalDriftScore - 1400) >= 0)
        {
            manager.totalDriftScore = manager.totalDriftScore - 1400;
            nayidiaBMW = true;
            m3Button.SetActive(false);
          
        }
        else if(((manager.totalDriftScore - 1400) < 0))
        {

            Debug.Log("CANT BUY THIS CAR");

        }
    }
}

i know i have to make it in update but…

No, you do not have to do it in Update. For that fact, you shouldn’t do it in Update. When you click the button to buy, you can activate the map at that point. When you switch to another car, you should disable the map and check if the car you switch to has been bought or not and if so, display that map and if not, leave the map disabled.

ill try that

how can i overlay somthing for example image over canvas it gets behind button, so objects behind wont be interactable?

UI components such as Images and buttons are rendered in the order they are listed in the hierarchy.

So, for example

canvas
-bgImage
-Button

The button is drawn on top of the bgImage

canvas
-button
-bgImage

The image, assuming it was big enough, would draw on top of the button and would hide it.

All ui components have a raycast target checkbox to determine if they intercept touches or clicks.

thank you i got it working