Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Feature Request Remove Dependency to Built-in Physics Package (com.unity.modules.physics)

Discussion in 'Universal Render Pipeline' started by ScallyGames, Dec 22, 2020.

  1. ScallyGames


    Sep 10, 2012
    I am currently working on a URP + DOTS project and when switching from the old built-in Physics system (com.unity.modules.physics) to the new Unity Physics (com.unity.physics) I tried to remove the built-in package to avoid using any of the old features (not sure if this is a useful workflow but I wanted to try at least).

    However, VolumeManager.cs uses UnityEngine.Collider, thus creating an otherwise unnecessary dependency to com.unity.modules.physics.
    Seeing as Unity is trying to make the different parts as isolated as possible it would be nice to remove this dependency, especially as the direction is towards DOTS and the new Unity Physics and it would be nice to be able to remove the old Physics package at some point from new projects.

    Apparently the same issue is true with a dependency to Physics 2D as ShadowCaster2D.cs uses Collider2D
  2. PandaMittens


    Jan 20, 2021
    This is causing us headaches too on our WebGL projects. We would like to toss overboard the 3-4MB of executable code that the Physics and Physics2D systems add, but due to URP we can't.
    goncalo-vasconcelos likes this.
  3. mitaywalle


    Jul 1, 2013

    You can resolve it this way:
    - copy URP package from Project/Library/PackageCache/ to Project/Packages/
    - separate 2D scripts to subfolder
    - scope all 2D-code with custom compile define symbol (URP_2D_OPTIONAL for example)
    - if you need to change only part of script, you can use same URP_2D_OPTIONAL
    - create there Assembly Defenition
    - add VersionDefine to physics2d and use same define symbol there
    Claytonious likes this.
  4. ScallyGames


    Sep 10, 2012
    While it is possible to locally fix it as described by @mitaywalle the point of this post is not to find a solution but to request a change in what seems like smelly code. This dependency between packages seems pretty unreasonable, especially since it is only on utility functions as far as I remember.

    Having to make local changes on each project and making sure these changes are applied for all contributers of the projects to be able to remove an unneeded (and possibly problematic) package just seems crazy.