0

I'm setting up my development environment to play around with Unity using C# via Visual Studio Community 2017 for Mac. But I can't figure out why it's not picking up even basic libraries like System.Collections. Bear in mind that I can actually run the code in Unity; this is purely an IntelliSense problem in VS.

I'm limited to using Mac El-Capitan (v10.11.6), hence I cannot upgrade to Visual Studio 2019. I'm currently running a freshly downloaded Unity version 2018.4.

I've checked the project settings and solution settings but nothing that appears to reference libraries to be included or similar, which is the issue implied by the error messages (below). I've taken a look at this fantastic post but all the options in Visual Studio indicated are missing. I feel that Visual Studio Community is a lite version of VS?

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class GameController : MonoBehaviour {
    public Text text;

    // Start is called before the first frame update
    void Start() {

    }

    // Update is called once per frame
    void Update() {
        text.text = Input.mousePosition.ToString("R");
    }
}

The error messages I get are:

The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
The type or namespace name 'UnityEngine' could not be found (are you missing a using directive or an assembly reference?)
The type or namespace name 'MonoBehaviour' could not be found (are you missing a using directive or an assembly reference?)

To conclude, how can I get IntelliSense working in VS?

Ahmed Tawfik
  • 1,159
  • 1
  • 8
  • 13
  • make sure to open the files from within Unity not via the file explorer – derHugo Aug 12 '19 at 11:57
  • The way I've opened the files is by double-clicking the file in the Assets panel in Unity. Is there a better way? – Ahmed Tawfik Aug 12 '19 at 11:59
  • Check for the exceptions in unity's console window – caxapexac Aug 12 '19 at 12:08
  • Afaik, unity won't create vs project files until successful compilation – caxapexac Aug 12 '19 at 12:09
  • No exceptions. I can see valid exceptions when I make them, but the above issues are still present in VS when Unity takes the code fine and runs it (and no exceptions present). – Ahmed Tawfik Aug 12 '19 at 12:10
  • So I've done some digging into the .csproj file and I've found a reference to System.dll: /Users/ahmedtawfik/Development/UnityProjects/2018.4.6f1/Unity.app/Contents/NetStandard/compat/2.0.0/shims/netfx/System.dll I've verified that it's actually there. – Ahmed Tawfik Aug 12 '19 at 12:33
  • Possible duplicate of [Autocompletion not working in Visual studio](https://stackoverflow.com/questions/42597501/autocompletion-not-working-in-visual-studio) – Draco18s no longer trusts SE Aug 12 '19 at 14:04
  • @Draco18s I'd have appreciated it if you'd noticed the sole link in this question was to the possible duplicate you posted :) Can you explain why it may resolve the question given my dev env? – Ahmed Tawfik Aug 13 '19 at 06:47
  • @AhmedTawfik Had to look again to even notice the link, it was kind of buried. No, I don't know how to resolve it. I just know that the problem is that the Unity tools haven't been installed correctly. Any time I've encountered that problem (literally once) I uninstall everything and start over. – Draco18s no longer trusts SE Aug 13 '19 at 13:21
  • Thanks for the update. To be fair, I agree it is a bit buried... Additionally, it seems that since I'm running El Capitan (MacOS 10.11), some .NET frameworks (or all?) are not supported, and thus I can't access them via Visual Studio 2017. But the code compiles because Unity accesses it through its own packaging... I think there's a solution but I've spent too much time looking at it today. Maybe later... – Ahmed Tawfik Aug 13 '19 at 15:10

0 Answers0