I’m working on a library to share between several of my projects, and it requires the JetBrains.Annotations
. I’m trying to use my library in a Unity project, but I can’t because I keep getting ambiguous reference errors because Unity includes it’s own set. Is thereany way to fix this? Even using extern aliases, I still can’t get it to properly work.
Have you looked into extern alias? I haven’t messed around with it much but it could potentially help you in this situation:
@bentontr I did, but it simply refused to differentiate the types in some cases.
Just use a using
directive for types hwere there’s a conflict. A common one in Unity is System.Random vs UnityEngine.Random. So you pick the one you want and use a using directive, a for example:
using Random = UnityEngine.Random;
UPDATE: My hackish solution was to remove the reference to the NuGet JetBrains.Annotations, and embed them in my shared library’s source code instead.
That won’t work. The problem is namespace collision. Both Unity’s set and the NuGet set have the exact same classes in the exact same namespace. That’s why i tried extern alias.
1 Like