Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Help with multiple references with same namespace in VisualStudio

Discussion in 'Scripting' started by acandael, May 25, 2023.

  1. acandael

    acandael

    Joined:
    Apr 7, 2021
    Posts:
    71
    Hello,

    I hope my question will make sense :D

    I am developing a Unity project in VisualStudio and compiling dlls that I then place in my Unity project. For this, I add as reference UnityEngine, UnityEngine.UI, etc. Everything works fine.

    Recently, I needed to also use a package (Unity Atoms), so I include that package dlls as reference in my VisualStudio project as well. And here is the part I don't get: I declare a BoolVariable (which is defined in the package), and VS tells me that 'ScriptableObject' is defined in an assembly that is not referenced... although UnityEngine is referenced.

    upload_2023-5-25_16-25-16.png

    Now, I'm getting out of my comfort zone, but I can indeed add a reference to UnityEngine.CoreModule instead. I don't really understand why I have to do this, but I guess it's because the BoolVariable class has a reference to UnityEngine.CoreModule, and not to UnityEngine (and why they did that, I don't know).

    Ok, so, I could do that and get away with it if I only used that package, but the thing is I am also using the Unity UI package. I'm using the Text class, for instance. And there, I have kind of the opposite problem: VS says I can't get a Text Component and ask for its gameObject, because Monobehaviour is defined in an assembly that is not referenced... Of course the solution here would be to use UnityEngine, not UnityEngine.CoreModule. But then I'm back to square one, since I can't have both references.

    Therefore.. what can I do?

    Thanks a lot for your help,
    Arnaud.
     

    Attached Files:

  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,563
    Just so you know, this workflow will endlessly cost you hassle and issues, such as the one you are experiencing.

    Unity is far better when you just drop code in. Submodules can let you share code. We use submodules at commercial scale, multiple shared submodules with many branches across dozens of different frequently-updated products. Using DLLs would cause us (actually DID cause us) massive harm.

    Share/Sharing source code between projects:

    https://forum.unity.com/threads/your-techniques-to-share-code-between-projects.575959/#post-3835837
     
    Last edited: May 26, 2023
    acandael likes this.
  3. acandael

    acandael

    Joined:
    Apr 7, 2021
    Posts:
    71
    Thanks a lot for your answer, will do as suggested!