Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Can get Visual Studio and Unity to connect.

Discussion in 'Scripting' started by cemyatt, Aug 17, 2018.

  1. cemyatt

    cemyatt

    Joined:
    Aug 17, 2018
    Posts:
    5
    I am trying to test out Unity, but I cannot seem to get the code to work. Whenever I try to put code on a property, it does this error message:

    "Can't add script behaviour CallbackExecutor. The script needs to derive from MonoBehaviour!"

    Even though I added ": MonoBehaviour" on the code.

    And when I load up my code on Visual Studio, this error message is in the Output box:

    "C:\Users\cemya\Documents\D&D Roguelight Project\Assembly-CSharp.csproj : error : The project file could not be loaded. Could not find file 'C:\Users\cemya\Documents\D&D Roguelight Project\Assembly-CSharp.csproj'. C:\Users\cemya\Documents\D&D Roguelight Project\Assembly-CSharp.csproj"

    I have the Visual Studio 2017 Tools for Unity on there, and Unity doesn't have the option to import the package, implying it's already imported. What's the real problem? I can post my code if it would help.
     
  2. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    20,965
    Check the name of the script file and the name of the script class. Be sure to match the casing of the letters too (eg if you used all lower case for one the other has to be all lower case too). This error is almost always because they don't match.
     
  3. cemyatt

    cemyatt

    Joined:
    Aug 17, 2018
    Posts:
    5
    I'm not too sure what you mean by this. I think the names of the script files match (i.e. the file for the NewRoll script is called NewRoll excluding the .cs) and it is in a "package" (which I think is the term for script class) which matches the name of the project. I'm probably getting this wrong, consider how confident you are.
     
  4. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    Maybe just post the script here then? Use CODE tags.
     
  5. cemyatt

    cemyatt

    Joined:
    Aug 17, 2018
    Posts:
    5
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class NewRoll : MonoBehaviour {
    6.  
    7.     // Use this for initialization
    8.     void Start () {
    9.        
    10.     }
    11.    
    12.     // Update is called once per frame
    13.     void Update () {
    14.        
    15.     }
    16. }
    17.  
     
  6. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    Are you sure this is the one with the problem? Your error message says the script is named CallbackExecutor.
     
  7. cemyatt

    cemyatt

    Joined:
    Aug 17, 2018
    Posts:
    5
    Yeah, that's the one.

    I'm pretty sure it's referred to as "NewRoll" in both Unity and in Visual Studio, so this is extremely weird.
     
  8. cemyatt

    cemyatt

    Joined:
    Aug 17, 2018
    Posts:
    5
    If it helps any, here's the package (or whatever it's called) I'm using for Unity in Visual Studios.
     

    Attached Files: