Search Unity

Question Package Manager file system error

Discussion in 'Package Manager' started by little_box, Mar 8, 2024.

  1. little_box

    little_box

    Joined:
    Aug 22, 2017
    Posts:
    28
    I had a problem when I tried to manage packages through code. If multiple identical packages appeared under the Packages folder, the file system would recognize an error.

    Let's say I have a package called "com.bc.test@0.0.2". I want to copy this package to a new folder "com.bc.test", API "Directory.Exists" will return true, but it doesn't.

    If I try to copy pacakge under Library/PackageCache to Packages had a same problem.

    I have a pacakge, for example, "Library/PackageCache/com.unity.2d.common@4.0.4", if I try to copy to "Packages/com.unity.2d.common", At this point "DirectoryInfo diTarget = new DirectoryInfo ("Packages/com.unity.2d.common")" Will be redirected to the "Library/PackageCache/com.unity.2d.common@4.0.4"

    Please tell me what is the reason? How to deal with this problem?
     
  2. maximeb_unity

    maximeb_unity

    Unity Technologies

    Joined:
    Mar 20, 2018
    Posts:
    556
    Hi @little_box,

    The Editor uses a virtual file system indirection that allows accessing package files via a stable path, regardless of their actual location on disk. There's a scripting API you can use to embed a package into your project
    UnityEditor.PackageManager.Client.Embed
    , which will copy it from whatever location to the project's Packages folder.