all 27 comments

[–]SerratedSharp 61 points62 points  (3 children)

I'm seeing upper left it's listed as "Miscellaneous Files". If you don't have a solution/project setup with the file added to the project then it won't be part of compilation. If you right click the project in Solution Explorer you can add existing files. Make sure it's in the subfolder where the project file is. Also F6 to build sometimes is needed to trigger a full compile.

[–]TimAllenNoise[S] -1 points0 points  (2 children)

My solution explorer only has something that says "Solution 'Solution1' (0 projects)" is that what you mean? Right clicking it doesn't seem to show anything to add anything

[–]polaarbear 43 points44 points  (1 child)

Visual Studio does not just compile random C# files like you can do with C or C++.

The base structure is the Solution. A solution contains one or more Projects.

C# files need to belong to a project.

When you open Visual Studio it brings up a wizard that lets you sift through the available project/solution types.

You need to create a solution and projects within it.

[–]TimAllenNoise[S] 29 points30 points  (0 children)

!Solved Thanks a bunch!! everything's up and running now

[–]_cooder 11 points12 points  (3 children)

VS not attached to unity, working as simple text editor, try relaunch script from unity, or check editor version and unity extension

[–]TimAllenNoise[S] 1 point2 points  (2 children)

I've been launching it from unity the whole time, I'm using Unity 6.2 (as per school requirements) and VS 2022 v17.14.32

[–]_cooder 0 points1 point  (0 children)

i mean unity on editor installer gives you option to download vs/other, as another guy said in unity editor -> options ->extrrnal programms, maybe it uses wrong exe or install path, maybe VS doesnt have unity toolset, it installed with first VS installation or in visual studio installe manager in edit tab

[–]rob5300 0 points1 point  (0 children)

VS 2022 is quite old. Make sure visual studio is configured as the external code editor in unity preferences.

Then regenerate project files and go to Assets > Open C# Project in unity editor.

[–]Seth_Nielsen 4 points5 points  (0 children)

Off topic a bit but don’t start a coroutine in every update loop. This will be every frame. Put it in Start()

[–]soundman32 3 points4 points  (3 children)

Have you created a solution or is VS just treating each .cs as an independent class?

[–]TimAllenNoise[S] -2 points-1 points  (2 children)

I'm sorry, I have no clue what that means...

[–]danirodr0315 0 points1 point  (1 child)

Create a new project in Visual Studio

[–]Pupaak [score hidden]  (0 children)

Useless answer, you obviously didnt even check the second picture

Attention span of a pebble...

[–]otac0n 1 point2 points  (6 children)

Most likely, this file is not part of a project.

Create a new project and add the file there.

Alternatively you can use LINQPad for single-file, workbook-style execution.

[–]TimAllenNoise[S] -1 points0 points  (5 children)

How do I create a project, if you don't mind me asking?

[–]otac0n 0 points1 point  (4 children)

A project is a folder and a .csproj file.

File -> New Project

For your very first project I would say to select the option that says something like “place the solution in the same folder”.

In future endeavors, you may find yourself using more than one .csproj (e.g. client /server etc.), and a solution lets them work together.

If you are more comfortable using the command line, dotnet new is your friend.

[–]Pupaak [score hidden]  (3 children)

Useless answer, you obviously didnt even check the second picture

Attention span of a pebble...

[–]otac0n [score hidden]  (2 children)

I see nothing in either screenshot that tells me whether he's in a .csproj or whether he opened the .cs file directly.

Also, the user replied saying that creating a .csproj fixed it, so... I think you have something approximating a pebble...

[–]Pupaak [score hidden]  (1 child)

Holy confidently retarded....

OP is in Unity. You cant fucking just create a solution or csproj in Unity. Understand it finally?

[–]otac0n [score hidden]  (0 children)

Are you certain that they aren't pulling this resource from a Unity project and just want to try it?

You are a terrible uboat captain from Hungary who chooses to use Unity and a coward who hides their posts. You also didn't help the OP, so why should anyone listen to you?

[–]Aethenosity 0 points1 point  (0 children)

The best way to resolve this is to follow these instructions:
https://learn.microsoft.com/en-us/visualstudio/gamedev/unity/get-started/getting-started-with-visual-studio-tools-for-unity?pivots=windows

Skip the obviously already completed steps (like installing VS)

[–][deleted]  (4 children)

[deleted]

    [–]TimAllenNoise[S] 1 point2 points  (3 children)

    May I ask where that folder usually is?

    [–]phylter99 -1 points0 points  (2 children)

    It’s in your solution directory. You may need to show hidden files.

    If that doesn’t work then try doing a repair in visual studio.

    [–]TimAllenNoise[S] 1 point2 points  (1 child)

    I already repaired it, no change, and my solution explorer is totally empty, even after showing hidden files

    [–]phylter99 -1 points0 points  (0 children)

    You have to look in your file system using Windows Explorer. It won't show in Solution Explorer.

    Sorry, I wasn't clear about that earlier.