Search Unity

Unity 2019.2.11f1: Edit code in scripts of packages and keep it permanently?

Discussion in 'Package Manager' started by Toastbyte, Nov 28, 2019.

  1. Toastbyte


    Sep 1, 2016

    I downloaded the sprite shape 2d package through the package manager and am currently using it for my project.

    I made some changes to one of the script of the package to make it suit my needs, but every time I restart unity, the changes I made in the script reset to the default code the package came with.

    Am I doing something wrong or is it not possible to edit the code of packages in the way I am?

    The path of the script I am editing is inside the project folder in:
    Last edited: Nov 28, 2019
  2. Johannski


    Jan 25, 2014
    As the name already suggests, the package cache is a cached version of a package which should always be the same everywhere the version of the package is imported. If you need to edit a script of a package, I think the best practice would be to create a git repo with the package and its changes, which you can import instead of the original asset.

    If you're not familiar with git or working alone on the project without the need for others to access the package you can also link to a package on the disk

    This package should be an own folder outsidde of any cache folder.
  3. cassandraL


    Unity Technologies

    Dec 7, 2017
    Hello @Toastbyte,

    As @Johannski suggests, you can indeed clone the package and `Add it from disk` to edit it. But this means that the package needs to be found at the same location on your colleagues' computer.

    Therefore, if you are multiple people working on this project, the recommended way is to simply embed the package under the "Packages" folder of the project.
    This means that you can copy the files from
    `\Library\PackageCache\com.unity.2d.spriteshape@2.1.0-preview.11\` into your project's `\Packages\com.unity.2d.spriteshape@2.1.0-preview.11\` folder.
    That way, the package is included in your project, checked-in with your project and will be the same for the whole team.

    You can choose the solution that best fits your needs.
    a436t4ataf and Toastbyte like this.