2015-12-09 48 views
2

我有一個與點語法相關的問題。使用點語法時的Unity Assembly參考錯誤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); 
     } 
    } 
} 

腳本之間的連接沒有工作,我得到這個錯誤:

error CS0234: The type or namespace name Scripts' does not exist in the namespace Assets.Code'. Are you missing an assembly reference?

在文件夾代碼中,有af存儲此LoadDiagram的較早的命名腳本,所以我不知道如何解決此問題。任何幫助深表謝意。

+0

如果您發佈實際代碼,則可能會得到更多相關答案;在當前狀態下的片段是無效的,re:'如果(LoadDiagram.diagramaCarga.TryGetValue(gametime,out test))'應該在方法中的類中。 –

回答

1

儘管您的文件LoadDiagram位於文件夾腳本中,但它不在命名空間「腳本」中。爲此,請將名稱空間「AssemblyCSharp」替換爲「Assets.Code.Scripts」,或者只刪除該使用語句。

+0

我曾嘗試過,但沒有成功,但它現在起作用,我認爲我們沒有更新的更改 – ClaudioA

1

LoadDiagram似乎位於第二代碼片段的AssemblyCSharp命名空間中。將名稱空間從AssemblyCSharp更改爲Assets.Code.Scripts並且應該解決該錯誤。