Search Unity

The project that creates a class library cannot be directly launched

Discussion in 'Getting Started' started by kikilinio, Aug 27, 2020.

  1. kikilinio

    kikilinio

    Joined:
    Aug 27, 2020
    Posts:
    2
    I created a project in a unity, created a c # script, the visual studio opens, I pressed start and an error appears. The project that creates a class library cannot be directly launched
    what did I do wrong? how to fix?
     
  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    What "start" button are you referring to? If you want to play your project in the editor you press the "Play" button at the top.
     
  3. kikilinio

    kikilinio

    Joined:
    Aug 27, 2020
    Posts:
    2
    start in visual studio. i did new unity project, created default c# script and tried to compile that script in visual studio
     
  4. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    You don't run Unity projects from VS. Unity isn't just a simple library you add to a VS project. If you want to build and run your project, you do it from the Unity Editor.
     
    Ryiah likes this.
  5. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    21,205
    Since @Joe-Censored touched on the way to make it work I'll touch on the technical explanation. Unity ships with its own compiler that is mostly equivalent to C# 7.3 and it's own framework that is mostly equivalent to .NET 4.6. Unity's runtime libraries expect your scripts to be compiled and implemented using these.

    If I remember correctly there used to be a way (and maybe it still exists but my searches turned up nothing) to start your game from within Visual Studio without having to switch focus to Unity but I don't believe that functionality exists now.
     
    Joe-Censored likes this.