c# - 使用 Dot 语法 c# 时 Unity 程序集引用错误

标签 c# unity-game-engine

我有一个与点语法相关的问题。

我有这样的情况(我只粘贴相关代码部分):

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 namespaceAssets.Code'. Are you missing an assembly reference?

在Code文件夹中,有一个名为scripts的文件夹,其中存储了这个LoadDiagram,所以我不知道如何解决这个问题。非常感谢任何帮助。

最佳答案

虽然您的文件 LoadDiagram 位于 Scripts 文件夹中,但它不在命名空间“Scripts”中。为此,请将命名空间“AssemblyCSharp”替换为“Assets.Code.Scripts”,或者仅删除该 using 语句。

关于c# - 使用 Dot 语法 c# 时 Unity 程序集引用错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34168862/

相关文章:

c# - WCF 服务代理未设置 "FieldSpecified"属性

c# - 如何摆脱编译器错误: C# use of unassigned local variable?

c# - 无法使用 Firebase 插入数据

android - Google Play 突然反对我的应用程序签名无效

c# - 为什么协程停止工作/执行

c# - Destroy() 和 DestroyImmediate() 有什么区别?

unity-game-engine - unity/vrtk 不包含定义错误

c# - 确定打开了哪个标签页

c# - Datagrid - 不要在每次属性更改时更新,仅在保存时更新

c# - 如何过滤嵌套关系