Search Unity

Question How to update code like Unity does by a version update?

Discussion in 'Testing & Automation' started by Kinggrass, Apr 5, 2023.

  1. Kinggrass

    Kinggrass

    Joined:
    Jun 7, 2016
    Posts:
    72
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    5,986
    What do you intend to do?

    Afaik it is not possible to hook into that process, ie to customize it.
    You can write your own editor script that determines a change in editor version between two runs, and act upon that event.
     
  3. Kinggrass

    Kinggrass

    Joined:
    Jun 7, 2016
    Posts:
    72
    I have a package, if I change the syntax of there APIs, I want to update other packages automatically to reflect these changes if they get loaded (custom packages, so they are writable). Not all Packages are always together loaded in one project, therefore those should then be updated with updater scripts which comes with the Package with the done changes.
     
  4. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    5,986
    Isn't that what package versioning is used for (among other things)?
    Unity ensures that packages work with 2019, 2020, 2021 and so on by setting a recommended package version based on the Unity version. So with 2020 you may get package v5.1.x installed but in 2021 you get v5.5.x instead. See for example the render pipeline packages.

    It certainly sounds weird to change the scripts of other packages, and it actually spells trouble I because doing a string search & replace can easily backfire. If you work with a team I would definitely use the package versioning and maintain those using source control branches. Even if we don't have these "recommended" versioning available that Unity has for their own packages (though I believe the "unity" field is used to signal compatibility), you could still instruct developers to use specific versions of each package depending on the Unity version.

    I would probably use the major version number on those packages and set it to 2020.x.x and 2021.x.x to signal to others which package version is the correct one to use for their project. That way they don't have to remember whether a given package version 4, 5 or 6 is compatible with Unity 2020.
     
    Kinggrass likes this.
  5. Kinggrass

    Kinggrass

    Joined:
    Jun 7, 2016
    Posts:
    72
    Thanks for your response.