Search Unity

How to add assembly in Unity?

Discussion in 'Scripting' started by raidshasd, Jan 18, 2020.

  1. raidshasd

    raidshasd

    Joined:
    Jan 12, 2020
    Posts:
    10
    The type name 'ZipArchive' could not be found in the namespace 'System.IO.Compression'. This type has been forwarded to assembly 'System.IO.Compression, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' Consider adding a reference to that assembly.


    I did add them in Visual Studio, but I don't know how to add them in Unity. I restarted the Unity in hopes that it could solve it, but it didn't.

    The only think I could find was:
    https://answers.unity.com/questions/1579827/unityenginewww-has-been-forwarded-to-an-assembly-t.html
    But that's about Unity's own namespace, but the one I want to add comes from System namespace. I add this reference to Visual Studio and it doesn't report the error anymore, but Unity does. Is there a way to have Unity include all the references needed?
     
    Last edited: Jan 18, 2020
    vitaliy-ostrovsky likes this.
  2. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,778
    Any reason 6oubtry why add zip file?
    What is inside?
     
    Last edited: Jan 18, 2020
  3. raidshasd

    raidshasd

    Joined:
    Jan 12, 2020
    Posts:
    10
    Nothing is inside, I can't even get the code to compile, much less actually reach a phase where what's in the zip file matters.
     
  4. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,778
    Ah, I think I am getting, what you try achieve.
    Do you try load some files from zip?

    Unity provides Resource folder, Assets Bundles, and some other methods, to load files. But not sure, if that is helpful in your case.
     
  5. raidshasd

    raidshasd

    Joined:
    Jan 12, 2020
    Posts:
    10
    Unfortunately not. But thanks for good thought.
     
  6. raidshasd

    raidshasd

    Joined:
    Jan 12, 2020
    Posts:
    10
    I've found out solution to thing I don't comprehend. If you have such issue happened to you, I've found couple solutions for couple different causes.

    1. In Visual Studio (I don't know about others) you need to add reference to whatever namespace you need. To do that in VS go
    Project > Add Reference
    , then select the namespaces you need and apply.
    If Unity won't react to the change, and you close Visual Studio and start it again, and it drops the reference:
    2. See in Unity, in
    Edit > Project Settings > Other Settings > Configuration > API compatibility
    and choose another version, and see if that fixes your problem.
    3. To forcibly add namespace to your project you can create an empty file called
    csc.rsp
    , put it in the Assets folder and write following in it:
    Code (CSharp):
    1. -r:System.IO.Compression.dll
    2. -r:System.IO.Compression.FileSystem.dll
    Essentially
    -r:{namespace}.dll


    I had the second issue, so I hadn't researched further, good luck!
     
    Last edited: Jan 18, 2020
    Olipool likes this.