Search Unity

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

Discussion in 'Scripting' started by MrBoogyBam, Mar 10, 2021.

  1. MrBoogyBam

    MrBoogyBam

    Joined:
    Mar 4, 2021
    Posts:
    23
    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
    Code (CSharp):
    1. using UnityEngine;
    2. using TMPro;
    3.  
    4. public class ShopManagerScript : MonoBehaviour
    5. {
    6.     public int[,] shopItems = new int[6, 6];
    7.  
    8.     public float PlayerCash;
    9.  
    10.     public TMP_Text PlayerCashTxt;
    11.  
    12.     void Start()
    13.     {
    14.         PlayerCashTxt.text = "$" + PlayerPrefs.GetFloat("PlayerCash").ToString();
    15.  
    16.         // IDs
    17.         shopItems[1, 1] = 1;
    18.         shopItems[1, 2] = 2;
    19.         shopItems[1, 3] = 3;
    20.         shopItems[1, 4] = 4;
    21.         shopItems[1, 5] = 5;
    22.         shopItems[1, 6] = 6;
    23.  
    24.         // Price
    25.         shopItems[2, 1] = 1000;
    26.         shopItems[2, 2] = 1000;
    27.         shopItems[2, 3] = 1000;
    28.         shopItems[2, 4] = 1000;
    29.         shopItems[2, 5] = 1000;
    30.         shopItems[2, 6] = 1000;
    31.     }
    32.  
    33.     public void Buy()
    34.     {
    35.         GameObject ButtonRef = GameObject.FindGameObjectWithTag("Event").GetComponent<EventSystem>().currentSelectedGameObject;
    36.     }
    37. }
    the code is in the empty GameObject ShopManager
     
  2. MrBoogyBam

    MrBoogyBam

    Joined:
    Mar 4, 2021
    Posts:
    23
    Nevermind, i just needed to add `using UnityEngine.EventSystems`
     
  3. noclipstudio

    noclipstudio

    Joined:
    Mar 2, 2021
    Posts:
    73
    Here for me even adding the EventSystems library still doesn't recognize the currentSelectedGameObject
     
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,689
  5. noclipstudio

    noclipstudio

    Joined:
    Mar 2, 2021
    Posts:
    73
    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