Меню

Using unityengine ui ошибка

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();
    }
}

enter image description here

Hamid Yusifli's user avatar

asked Apr 23, 2020 at 18:09

Amstergo's user avatar

4

For Visual Studio Code (VSCode) not detecting UnityEngine.UI, you can follow these steps to solve possible issues.

  1. In Unity, go to Window/Package Manager
  2. Search for «Visual Studio Code Editor»
  3. Downgrade to version 1.2.3 (or upgrade to 1.2.5, seems like 1.2.4 is the problem)
  4. In Window/Package Manager, Search for «Unity UI»
  5. Re-install the package
  6. In Edit/Preferences/External Tools, check the «Registry packages» option
  7. In Edit/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.

answered Feb 3, 2022 at 19:34

Saleh Hosseini's user avatar

2

From this unity thread:

  • 1) Close Unity and any code editors you have open
  • 2) Make a backup of the Library folder from your project folder to your desktop
  • 3) Delete the Library folder from your project folder
  • 4) Open your project (Unity will rebuild the Library folder)
  • 5) Close Unity
  • 6) Delete the newly generated Library folder
  • 7) Move the Library folder (you backed up earlier) from your desktop back into your project folder
  • 8) Open your project
  • 9) Open one of your scripts
    UnityEngine.UI should be fine now

answered Apr 23, 2020 at 18:53

Hamid Yusifli's user avatar

Hamid YusifliHamid Yusifli

8,6962 gold badges23 silver badges48 bronze badges

1

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

answered Feb 14, 2021 at 17:55

Barış Can Yılmaz's user avatar

  1. Switch to VS Community under External Script Editor.
  2. Regenerate project files
  3. Switch back to VS Code.
  4. DON’T regenerate project files.
  5. Restart everything.

answered Dec 22, 2021 at 18:11

AmyyazdaN's user avatar

AmyyazdaNAmyyazdaN

3031 silver badge9 bronze badges

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.

answered Jan 10 at 16:09

Abdulkadır Gur's user avatar

using UnityEngine.UI; — как исправить ошибку?

Приветствую, что мне надо сделать что быч это исправить? AssetsFPS Kit 3.0ScriptsPlayerPlayerNetwork.cs(23,9): error CS0619: ‘GUIText’ is obsolete: ‘GUIText has been removed. Use UI.Text instead.’

Я понимаю что он устарел, но что сделать? Unity 2020

Последний раз редактировалось daniilkas123 28 дек 2019, 22:45, всего редактировалось 1 раз.

daniilkas123
UNец
 
Сообщения: 34
Зарегистрирован: 04 дек 2019, 01:21

Re: Как изменить/удалить GUITEXT

Сообщение 1max1 28 дек 2019, 22:27

что сделать?

Use UI.Text instead.

Аватара пользователя
1max1
Адепт
 
Сообщения: 5281
Зарегистрирован: 28 июн 2017, 10:51

Re: Как изменить/удалить GUITEXT

Сообщение daniilkas123 28 дек 2019, 22:32

1max1 писал(а):

что сделать?

Use UI.Text instead.

AssetsFPS Kit 3.0ScriptsPlayerPlayerNetwork.cs(23,9): error CS0246: The type or namespace name ‘UI’ could not be found (are you missing a using directive or an assembly reference?)

using UnityEngine.UI; — добавлено, но все равно

Перевел так же все понял только одно что тип не найден, а хотя у меня есть это

Используется csharp

public UI.Text nameLabel;
        public UI.Text nameLabelShadow;

daniilkas123
UNец
 
Сообщения: 34
Зарегистрирован: 04 дек 2019, 01:21

Re: using UnityEngine.UI; — как исправить ошибку?

Сообщение 1max1 28 дек 2019, 23:47

Используется csharp

using UnityEngine.UI;
//
public Text nameLabel;

Или сразу:

Используется csharp

public UnityEngine.UI.Text nameLabel;

Аватара пользователя
1max1
Адепт
 
Сообщения: 5281
Зарегистрирован: 28 июн 2017, 10:51


Вернуться в Общие вопросы

Кто сейчас на конференции

Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 14



I’m using 2019.3.0a4 version

When I add atoms on package manager this i what I see on my console, any Idea of what could be happening?

[CompilerError] The type or namespace name ‘UI’ does not exist in the namespace ‘UnityEngine’ (are you missing an assembly reference?)
Compiler Error at LibraryPackageCachecom.mambojambostudios.unity-atoms@163a216SourceMonoHooksOnButtonClickHook.cs:2 column 19
1: using UnityEngine;
—>2: using UnityEngine.UI;
4: namespace UnityAtoms

[CompilerError] The type or namespace name ‘EventSystems’ does not exist in the namespace ‘UnityEngine’ (are you missing an assembly reference?)
Compiler Error at LibraryPackageCachecom.mambojambostudios.unity-atoms@163a216SourceMonoHooksOnPointerDownHook.cs:2 column 19
1: using UnityEngine;
—>2: using UnityEngine.EventSystems;
4: namespace UnityAtoms

[CompilerError] The type or namespace name ‘IPointerDownHandler’ could not be found (are you missing a using directive or an assembly reference?)
Compiler Error at LibraryPackageCachecom.mambojambostudios.unity-atoms@163a216SourceMonoHooksOnPointerDownHook.cs:7 column 55
5: {
6: [AddComponentMenu(«Unity Atoms/Hooks/On Pointer Down»)]
—>7: public sealed class OnPointerDownHook : VoidHook, IPointerDownHandler
8: {
9: public void OnPointerDown(PointerEventData eventData)

[CompilerError] The type or namespace name ‘PointerEventData’ could not be found (are you missing a using directive or an assembly reference?)
Compiler Error at LibraryPackageCachecom.mambojambostudios.unity-atoms@163a216SourceMonoHooksOnPointerDownHook.cs:9 column 35
7: public sealed class OnPointerDownHook : VoidHook, IPointerDownHandler
8: {
—>9: public void OnPointerDown(PointerEventData eventData)
10: {
11: OnHook(new Void());

[CompilerError] The type or namespace name ‘Button’ could not be found (are you missing a using directive or an assembly reference?)
Compiler Error at LibraryPackageCachecom.mambojambostudios.unity-atoms@163a216SourceMonoHooksOnButtonClickHook.cs:7 column 30
5: {
6: [AddComponentMenu(«Unity Atoms/Hooks/On Button Click»)]
—>7: [RequireComponent(typeof(Button))]
8: public sealed class OnButtonClickHook : VoidHook
9: {

0 / 0 / 0

Регистрация: 14.03.2020

Сообщений: 14

1

14.03.2020, 13:17. Показов 3151. Ответов 2


C#
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
 
public class CoinManager : MonoBehaviour
{
    
    public static MoneyManagerScr Intance;
    public Text MoneyTxt;
    public int GameMoney;
    void Awake()
    {
        Intance = this;
    }
    void Update()
    {
        MoneyTxt.text = GameMoney.ToString();
    }
 
}
}

Errors:
{
«resource»: «/d:/unity/Sniko/Assets/Scripts/CoinManager.cs»,
«owner»: «csharp»,
«code»: «CS0234»,
«severity»: 8,
«message»: «Тип или имя пространства имен «UI» не существует в пространстве имен «UnityEngine» (возможно, отсутствует ссылка на сборку). [Assembly-CSharp]»,
«source»: «csharp»,
«startLineNumber»: 4,
«startColumn»: 19,
«endLineNumber»: 4,
«endColumn»: 21
}
{
«resource»: «/d:/unity/Sniko/Assets/Scripts/CoinManager.cs»,
«owner»: «csharp»,
«code»: «CS0246»,
«severity»: 8,
«message»: «Не удалось найти тип или имя пространства имен «MoneyManagerScr» (возможно, отсутствует директива using или ссылка на сборку). [Assembly-CSharp]»,
«source»: «csharp»,
«startLineNumber»: 9,
«startColumn»: 19,
«endLineNumber»: 9,
«endColumn»: 34
}
{
«resource»: «/D:/unity/Sniko/Assets/Scripts/CoinManager.cs»,
«owner»: «csharp»,
«code»: «CS0246»,
«severity»: 8,
«message»: «Не удалось найти тип или имя пространства имен «Text» (возможно, отсутствует директива using или ссылка на сборку). [Assembly-CSharp]»,
«source»: «csharp»,
«startLineNumber»: 10,
«startColumn»: 12,
«endLineNumber»: 10,
«endColumn»: 16

__________________
Помощь в написании контрольных, курсовых и дипломных работ, диссертаций здесь



0



0 0 голоса
Рейтинг статьи
Подписаться
Уведомить о
guest

0 комментариев
Старые
Новые Популярные
Межтекстовые Отзывы
Посмотреть все комментарии

А вот еще интересные материалы:

  • Яшка сломя голову остановился исправьте ошибки
  • Ясность цели позволяет целеустремленно добиваться намеченного исправьте ошибки
  • Ясность цели позволяет целеустремленно добиваться намеченного где ошибка
  • Using render selected with empty selection ошибка
  • Using namespace system c ошибка