简体   繁体   中英

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?)

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;'

For some reason unity can't find the type/namespace. Anyone that can help me fix this?

  • Go to your GameManger.cs
  • Find the line that starts with namespace <anything>
  • Copy that <anything>
  • Add it to the top of your FightingIdle with using <anything>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM