Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by ryandotdee · Dec 23, 2017 at 08:31 PM · scripting problemunityeditor

Cannot resolve unity container

I am having a ton of trouble trying to use UnityContainer. Unity will not compile my scripts as it keeps giving me this message :


'The type or namespace name Unity could not be found. Are you missing an assembly reference?'

'The type or namespace name UnityContainer could not be found. Are you missing an assembly reference?'


I have been digging around on the web for ages, and have found some people with similar, but not exactly the same problem. So far I have tried :

  • Uninstalling / Reinstalling Unity (2017.3.0f3)

  • Uninstalling / Reinstalling Visual Studio ( 2017 )

  • Changed unity player settings to use Experimental .NET 4.6 equivilant

I have used NuGet to install the Unity Container project, and everything resolves and builds fine in Visual Studio, but Unity keeps giving the missing Namespace error.

I am completely stuck, and at a bit of a loss because I need to use the features UnityContainer provides in order to progress with my game. I have considered using an older version of Unity, but I really want to use the new tilemaps feature. I would be incredibly grateful for any assistance.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Alanisaac · Dec 23, 2017 at 08:48 PM

AFAIK, Unity and NuGet don't play nicely by default. Have you tried the suggestions in this article? You might be hitting the issue where Unity essentially wipes out your packages. I'll note that the "old version of mono" isn't really an issue anymore if you're targeting the 4.6 equivalent. From that article:


The difficulties of using NuGet with Unity boil down to the following issues:

  • Unity is built on an old version of Mono. So we are limited in what we can use from NuGet.

  • Unity sets our Target Framework by default to something that will prevent most NuGet packages from being installed.

  • Unity regenerates its Visual Studio solution, which wipes out installed packages.

  • Unity only recognizes DLLs placed under the Assets folder, by default NuGet won't install packages where we want them.

Comment
Add comment · Show 6 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image ryandotdee · Dec 23, 2017 at 08:56 PM 0
Share

Will have a read now, thanks for the response. Will let you know how I get on

avatar image ryandotdee · Dec 23, 2017 at 09:02 PM 0
Share

Ok, so I think I have fixed it. I skimmed through the article, and the symptoms made sense. Firstly I thought, Perhaps if I add the unity reference directly to the project ins$$anonymous$$d of relying on package manager. But then realized you cant do that. So I added a Pluggins folder in my assets directory, and dragged the appropriate assemblies in from the package, now it is compiling! Do you think this is an appropriate course of action?

avatar image Alanisaac ryandotdee · Dec 23, 2017 at 09:16 PM 0
Share

That definitely works. If you're happy with that solution, I'd say stick with that. If you'd like to take it a step further and NuGet working, the relevant section of that article is under "Nuget config file". Reproduced the snippet from that article below. Note that you may have to restore packages after modifying the configuration.


To install NuGet packages into Unity and have them survive Unity's regeneration of the solution, you must create a custom NuGet configuration file that instructs NuGet to store it's packages under Unity's Assets folder ins$$anonymous$$d of under a packages folder next to the solution (which isn't in the Assets folder). Our DLLs must live under the Assets folder so that Unity can find them and including them in the solution when it is regenerated.

Create a file called nuget.config next to the solution for your project (the sln file).

Note the packages.config file. NuGet generates this file (it won't exist until you install your first package), it contains a list of packages you have installed in the project.

The only setting we need in nuget.config is repositoryPath. We use this to tell NuGet to install packages under the Assets directory. Your nuget.config should look like this:

 <?xml version="1.0" encoding="utf-8"?>
 <configuration>
     <config>
         <add key="repositoryPath" value=".\Assets\packages" />
     </config>
 </configuration>

After creating the NuGet config file you should restart Visual Studio to make sure the config changes take effect.

avatar image ryandotdee · Dec 23, 2017 at 09:14 PM 0
Share

Ugg, so unity builds it, but now it does not build in VS, I am going to follow that article and see if that fixes it

avatar image ryandotdee · Dec 23, 2017 at 10:14 PM 0
Share

I have followed the guide, and I am progressing. I am just getting weird issues where unity is messing with the sln. If i create a new project and add the nuget config file, I get no compiler errors in VS or Unity. Once I start adding scripts and doing stuff to them, Unity is doing something to the solution as I keep getting the "Solution modified outside of the environment" message, then things go wrong. The nuget config file gets deleted, and I start getting build errors in VS

avatar image ryandotdee · Dec 23, 2017 at 11:52 PM 0
Share

Thanks a million. I have managed to get it working now, really appreciate your help :)

avatar image
0

Answer by ryandotdee · Dec 23, 2017 at 11:51 PM

I would love to say it was easy, but, it was not lol. But I think I am there now.

  1. Change player settings to target .NET 4.6

  2. Create nuget.config file

  3. Install UnityContainer via nuget

  4. Unity will complain about duplicate references, so go into assets/packages/Unity .5.5.0/lib/ and delete every folder except net45

I was compounding my problem as I switched back to VS 2015 while I was trying to work this out which did not have the right .NET targeting pack installed. IF you use latest VS, your csproj file will retain the correct target framework which keeps it all working

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

125 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Video Player shows last frame at which it was stopped 0 Answers

GameObject uses his "own" Transform 0 Answers

How do I make an unusable and hidden button until certain conditions are met ? 1 Answer

Assembly Definition Files exclude specified subfolder 0 Answers

MaxST SDK Pink Screen 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges