簡體   English   中英

使用點語法 c# 時出現 Unity 程序集引用錯誤

[英]Unity Assembly Reference Error when using Dot syntax c#

我有一個與點語法相關的問題。

我有這個條件(我只是粘貼相關的代碼部分):

using UnityEngine;
using Assets.Code.Interfaces;
using Assets.Code.Scripts;
using System.Collections;  // dicionario
using System.Collections.Generic;  // dicionario

namespace Assets.Code.States

if (LoadDiagram.diagramaCarga.TryGetValue(gametime, out test)) // Returns true.
            {
                GUI.Box (new Rect (Screen.width - 650, 275, 50, 25),  test.ToString ());
            }

然后我有存儲這個 LoadDiagram 的腳本:

using UnityEngine;
using Assets.Code.Interfaces;
using System.Collections;  // dicionario
using System.Collections.Generic;  // dicionario
using System;
namespace AssemblyCSharp
{
    public class LoadDiagram
    {
        public LoadDiagram ()
        {
            Dictionary<int, float> diagramaCarga = new Dictionary<int, float>();

            diagramaCarga.Add(0, 4.2F);
            diagramaCarga.Add(1, 4F);
            diagramaCarga.Add(2, 3.6F);
            diagramaCarga.Add(3, 3.4F);
        }
    }
}

腳本之間的這種連接不起作用,我收到此錯誤:

錯誤 CS0234:命名Scripts' does not exist in the namespace Assets.Code' Scripts' does not exist in the namespace類型或命名空間名稱Scripts' does not exist in the namespace '。 您是否缺少程序集參考?

在文件夾Code中,有一個名為scripts的文件夾,就是存放這個LoadDiagram的,所以不知道怎么解決。 任何幫助深表感謝。

盡管您的文件 LoadDiagram 位於文件夾 Scripts 中,但它不在命名空間“Scripts”中。 為此,請將命名空間“AssemblyCSharp”替換為“Assets.Code.Scripts”,或者刪除該 using 語句。

LoadDiagram似乎位於第二個代碼片段的AssemblyCSharp命名空間中。 將命名空間從AssemblyCSharp更改為Assets.Code.Scripts ,這應該可以解決錯誤。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM