Consistent way to access Physics Category Names

Hello,
How can I load and use the same PhysicCategoryNames scriptable object than Unity engine will be using?
It looks like, no matter where the asset is, Unity engine will find it. But if there is several, how could I know which one is used?
Honestly I don’t think this could happen otherwise than human error. But I still would like to have a consistent access to the asset used, like the PhysicShape editor drawner (not directly, but it’s for the idea) can reference category names and select them.

Thanks :slight_smile:

Not sure how it works exactly, but PhysicsShapeAuthoring is connected to PhysicCategoryNames via PhysicsCategoryTags. You can probably do something similar.

Please let me know if this helps and feel free to ask for further assistance if needed.

Thanks! I already searched and didn’t figure out how it was working so that’s why I’m here ^^

The connection between PhysicsCategoryTags and PhysicCategoryNames is made in PhysicsCategoryTagsDrawer (see com.unity.physics\Unity.Physics.Editor\PropertyDrawers\TagsDrawer.cs).
A quick test has shown that duplicating the asset file would raise a warning in editor and latest file would be used.

This seems like a general Unity editor question, so I’d advise posting in a different subforum if you need further assistance or more details on how it works under the hood. I hope you’ll manage to work it out from here and further help won’t be needed, just wanted to set your expectations from people who monitor this subforum. :slight_smile:

1 Like

Discussion of a Unity Physics for ECS feature on a Unity Physics for ECS forum seems like a great fit. Continuing the thread…

Attached is the error that is shown if more than one file exists.

Unity’s current support for exactly one copy of a given file (PhysicCategoryNames.asset) has limitations. For example, a 3rd-party asset using this system cannot include its own PhysicCategoryNames.asset easily if the core project already has one.

Instead, I’d like to see a way to manually choose which PhysicCategoryNames.asset file is used. Perhaps on a per-project, per-scene, or per-component basis. One workflow would be to require this be set by dragging one instance of one of the PhysicCategoryNames.asset files into a panel in the Unity Project Settings window. That solution is not great as it still requires manually merging names in some use cases.

Thoughts?