简体   繁体   English

错误 CS0246,unity 找不到命名空间

[英]error CS0246, unity cannot find a namespace

I will try to summarize my problem as best as i can but i am very new to using this program.我会尽量总结我的问题,但我对使用这个程序很陌生。

I want to reference to a gamemanager in unity so that i can use certain values that i created in a different script.我想统一引用一个游戏管理器,以便我可以使用我在不同脚本中创建的某些值。 The full error is this:完整的错误是这样的:

Assets\\FightingIdle.cs(8,12): error CS0246: The type or namespace name 'GameManager' could not be found (are you missing a using directive or an assembly reference?) Assets\\FightingIdle.cs(8,12):错误 CS0246:找不到类型或命名空间名称“GameManager”(您是否缺少 using 指令或程序集引用?)

This is my code:这是我的代码:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class FightingIdle : MonoBehaviour
{
    public GameManager GM;
    // Start is called before the first frame update
    void Start()
    {

}

// Update is called once per frame
void Update()
{

}

void VechtKnop()
{
    GM.FightPoints += GM.FightDamage;
}

} }

The problem occurs here: 'public GameManager GM;'问题出现在这里:'public GameManager GM;'

For some reason unity can't find the type/namespace.由于某种原因,unity 找不到类型/命名空间。 Anyone that can help me fix this?谁能帮我解决这个问题?

  • Go to your GameManger.cs转到您的GameManger.cs
  • Find the line that starts with namespace <anything>找到以namespace <anything>开头的行
  • Copy that <anything>复制那个<anything>
  • Add it to the top of your FightingIdle with using <anything> using <anything>将其添加到 FightingIdle 的顶部

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Unity + Leap Motion:错误CS0246(命名空间)问题 - Unity + Leap Motion: error CS0246 (namespace) issue Unity 3d 错误 CS0246:找不到类型或命名空间名称“ParticleEmitter” - Unity 3d error CS0246: The type or namespace name 'ParticleEmitter' could not be found Unity引发错误“ CS0246:找不到类型或名称空间名称&#39;SharpKml&#39; - Unity throws an error “CS0246: The type or namespace name ‘SharpKml’ could not be found 如何解决 CS0246 错误:(类型或命名空间名称错误)? - How to resolve CS0246 ERROR: (The type or namespace name Error)? 错误 CS0246:找不到类型或命名空间名称“KustoConnectionStringBuilder” - error CS0246: The type or namespace name 'KustoConnectionStringBuilder' could not be found 错误CS0246:找不到类型或命名空间名称“AssemblyFileVersion” - Error CS0246: The type or namespace name 'AssemblyFileVersion' could not be found 错误 CS0246:找不到类型或命名空间名称“Newtonsoft” - Error CS0246: The type or namespace name 'Newtonsoft' could not be found InternalsVisibleTo导致CS0246错误:找不到类型或命名空间 - InternalsVisibleTo causes CS0246 error: The Type or Namespace could not be found 错误 CS0246:找不到类型或命名空间名称“CsvHelper” - error CS0246: The type or namespace name 'CsvHelper' could not be found 错误 CS0246:找不到类型或命名空间名称“IApplicationBuilderExtensions” - error CS0246: The type or namespace name 'IApplicationBuilderExtensions' could not be found
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM