Zoltan Torok
Zoltan Torok

Reputation: 73

Unity Scripts Not Recognised By Visual Studio

I'm making C# scripts for Unity (version 2021.3.8f1) and editing them in Visual Studio (2019) for a tabletop game.

In Unity I have a Visual Studio Editor Package and in Visual Studio I have a "Tools for Unity" tool. In Unity my folder hierarchy is Assets>Scripts>... . I have 3 scripts, "Route.cs", "Node.cs", "Stone.cs".

Route.cs works fine, it shows a Gizmo in Unity connecting all correlated Nodes. When I try to make the Stone script to tell it where it can move and its other functionalities, I notice a few things out of order. When I access Solution Explorer (I'm trying to see the Directory structure in which my scripts are, like I can in Unity), it tells me "Solution 'Name of my current project/solution' (0 projects)". That's my first clue something is not going right. I have a class Route in Route.cs and a homonymous class for each script. When I try to use the classes Route and Node in Stone.cs, they don't get highlighted, even though they do get in their own highlights in their respective scripts, and I can't use the inherited Lists of those classes.

I import: using System.Collections; using System.Collections.Generic; using UnityEngine; but not the scripts between each other (and I don't think that should be necessary).

I'm new to both Unity, C# and making inter-related scripts. What should I check or do?

Upvotes: 0

Views: 846

Answers (1)

Zoltan Torok
Zoltan Torok

Reputation: 73

Ok, I found my issue. I updated Visual Studio, it fixed my highlighting and Solution Explorer problems (I did have to import the other scripts from the Unity folder) and I was getting a Unity Console error because I used a List instead of a Route for something. All is good.

Visual Studio 2019 is still compatible with Unity 2021, someone suggested that Tools for Unity might be too old. It's not yet.

Upvotes: 1

Related Questions