Name Space Doesn't Exist CoordinateLabeller Script

Hi Guys,

Hope somebody can give me a point in the right direction here.

Been trying to figure this one out, even went as far as verbatim copying from GitHub, but still the error message persists (see attached) I assume it refers to the assembly, but this is the same as instructors.

Any ideas?

Cheers
le_bonn

Hi @le_bonn,

Welcome to our community! :slight_smile:

Which version of Unity do you use? And do you use Visual Studio or Visual Studio Code? If the latter, maybe this could help.

Hi Nina,

Thanks for the super efficient response.

I am using 2020.1.15f1

Best
Liam

I am also using Visual Studio (Mac version)

There was a problem with IntelliSense in one of the 2020 versions. Since you are using an outdated version, maybe you could try to update to the latest stable version of 2020.

Thanks Nina,

I will give it a go.

Hi,

I have updated to 2020.3 (latest release) and error persists. Any other ideas?

I could just continue using original undivided coordinates, but worry this might cause me bother later?

Cheers
le_bonn

Full Code

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;

[ExecuteAlways]

public class coordinateLabeler : MonoBehaviour
{
TextMeshPro label;
Vector2Int coordinates = new Vector2Int();

void Awake()
{
    label = GetComponent<TextMeshPro>();
    DisplayCoordinates();
}


void Update()
{
    if(!Application.isPlaying)
    {
        DisplayCoordinates();
    }

    updateObejectName();
}

 

void DisplayCoordinates()
{
    coordinates.x = Mathf.RoundToInt(transform.parent.position.x / UnityEditor.EditorSnapSettings.move.x);
    coordinates.y = Mathf.RoundToInt(transform.parent.position.z / UnityEditor.EditorSnapSettings.move.z);
    label.text = coordinates.x + "-" + coordinates.y;
}

void updateObejectName()
{
    transform.parent.name = coordinates.ToString();
}

}

Hi,

Strangely, even though error message persists in VS, it all works fine in Unity, with code working as expected, to divide coordinates…

Hi there,

I think I am getting closer to the route of the issue. It seems to be an issue with VS. It isn’t recognising the System.Collections “namespace”. See attached. I have updated and restarted VS but it persists. Any Ideas? As you can see, it is causing problems across all scripts.

Best le_bonn

Both your file and your class are named “Waypoint”, aren’t they? And there must not be any compiler errors in the Waypoint script.

Close Unity and VS. Then go to your project folder and delete the *.sln and *.csproj files. Start Unity again. Double click on the EnemyMover script inside your Assets folder to have Unity start VS. If you are lucky, the problem is gone.

If not, go to your Assets folder in Unity, click the right mouse button, then “Reimport all”.

Thanks Nina,

Deleting the files worked, all errors in VS are now fixed on both scripts.

Thanks again for your help, and I will remember that trick if I run into any unexplained errors in the futre.

Best
Le_bonn

I’m glad I was able to help. :slight_smile:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms