Reputation: 43
I want to display the number of coins on the screen, but I have error into my VScode:
The type or namespace name "UI" does not exist in the namespace "UnityEngine"
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class Main : MonoBehaviour {
public Player player;
public Text coinText;
public Image[] hearts;
public Sprite isLife, noneLife;
void Start() {
}
void Update() {
coinText.text = player.getCoins().ToString();
Lose();
}
}
Upvotes: 3
Views: 14510
Reputation: 1
Hi Bro Solved the problem, very simple. Delete Unity Hub.If not solved, download a new version of unity, don't run it with the hub. Then run it with the hub.
Upvotes: 0
Reputation: 523
For Visual Studio Code (VSCode) not detecting UnityEngine.UI, you can follow these steps to solve possible issues.
Window/Package Manager
Window/Package Manager
, Search for "Unity UI"Edit/Preferences/External Tools
, check the "Registry packages" optionEdit/Preferences/External Tools
, click the "Regenerate project files" button"If that didn't fix the problem, downgrade "Visual Studio Code Editor" to 1.1.3 instead.
Then you have to manually delete .csproj and .sln files at the root of your project and restart Unity.
Upvotes: 9
Reputation: 311
Upvotes: 1
Reputation: 735
I had a same issue. I changed visual studio code editor version to 1.2.1 in Windows > Package Manager > Visual Studio Code Editor section; I hope it helps
Upvotes: 0
Reputation: 10137
From this unity thread:
Upvotes: 3