The type or namespace name 'EventSystem' could not be found

so i’m following a tutorial on how to make a shop and after writing the code i got an error that said “The type or namespace name ‘EventSystem’ could not be found”

here’s the code

using UnityEngine;
using TMPro;

public class ShopManagerScript : MonoBehaviour
{
    public int[,] shopItems = new int[6, 6];

    public float PlayerCash;

    public TMP_Text PlayerCashTxt;

    void Start()
    {
        PlayerCashTxt.text = "$" + PlayerPrefs.GetFloat("PlayerCash").ToString();

        // IDs
        shopItems[1, 1] = 1;
        shopItems[1, 2] = 2;
        shopItems[1, 3] = 3;
        shopItems[1, 4] = 4;
        shopItems[1, 5] = 5;
        shopItems[1, 6] = 6;

        // Price
        shopItems[2, 1] = 1000;
        shopItems[2, 2] = 1000;
        shopItems[2, 3] = 1000;
        shopItems[2, 4] = 1000;
        shopItems[2, 5] = 1000;
        shopItems[2, 6] = 1000;
    }

    public void Buy()
    {
        GameObject ButtonRef = GameObject.FindGameObjectWithTag("Event").GetComponent<EventSystem>().currentSelectedGameObject;
    }
}

the code is in the empty GameObject ShopManager

Nevermind, i just needed to add using UnityEngine.EventSystems

Here for me even adding the EventSystems library still doesn’t recognize the currentSelectedGameObject

UnityEngine.UI is now a package:

Annoying possible issue circa October 2021:

1 Like

I just managed to remove and install UnityEngine.UI again but it didn’t solve for me, I tested the same script on another version of unity and it worked, really the problem is Unity version 2020.3.19 in my case