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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Asset namespace not found

Discussion in 'Editor & General Support' started by Bluzeere, Jul 23, 2018.

  1. Bluzeere

    Bluzeere

    Joined:
    Mar 15, 2017
    Posts:
    7
    I bought an asset from the store (Rewired). Everything seemed to install fine, but to do the parts that imply scripts, I need to use its libraries. However, typing "using Rewired;" as in the documentation returns an error ("the type or namespace name Rewired could not be found"). It's like it cannot detect the libraries.

    I did switch Unity versions mid-project. I was using Unity 5.5.0f.3 but a bug in sprites slicing forced me to upgrade to Unity 2018.1.0f2. Ever since that change, in any new script I created, I'd have to click File -> move xscript.cs into -> projectname to get my script to be recognized by my project. Maybe it is a similar problem, but I cannot figure out how to fix it and get the asset library to be recognized.

    I have tried moving the entire Rewired folder into the Scripts folder, or deleting it and re-importing the package, deleting .sln and .csproj (they would not rebuild automatically like I was told). I have even tried opening all Rewired .dll files in the Libraries folder and doing the same File -> move file into -> projectname like with the other scripts. Nothing works and Visual Studio will NOT recognize the Rewired namespace.

    Please help me. I am going crazy here.
     
  2. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,549
    Last edited: Jul 23, 2018
  3. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,508
    Please clarify:
    Is Unity giving this error or just visual studio? That makes a big difference because if Unity is giving you the error, the Rewired_Core.dll is not being imported by Unity. If only Visual Studio is giving you the error, that means the csproj does not have the reference to the DLL. Both of these issues are Unity's responsibility. Rewired can't control the library linking process as this is handled by Unity.

    You can manually add the reference to the DLL in visual studio, but you shouldn't have to and if there's something wrong with the project, the next time you import a script it's just going to remove that reference.

    Unity does and will rebuild the csproj files when you delete them. If it didn't, nothing could be compiled because Unity uses these csproj files to build the final assemblies used in the editor and in game builds. Delete them, re-import a script or a DLL in the Unity Editor, and they will be recreated.
     
    Last edited: Jul 23, 2018
    Bluzeere likes this.
  4. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,508
    Do you happen to have any .asmdef files in your project?
     
  5. Bluzeere

    Bluzeere

    Joined:
    Mar 15, 2017
    Posts:
    7
    Thanks for the help. It was solely Visual Studio giving the error at that point, not Unity itself.

    For anyone running into this kind of problem in the future with any new asset, the issue was fixed by updating Visual Studio's Tools for Unity (I believe VS gave me the warning when I tried to rebuild solution). I'm not sure why but even if they were not that old (I started within the last year) the old "tools" system may have had an issue properly detecting references within a solution if the Unity version was changed mid-project?

    Anyway, thanks again for helping.
     
  6. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,508
    Glad you solved it.