Skip to content

refactor: remove animation, physics and physics2d dependencies #1812

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions com.unity.netcode.gameobjects/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ Additional documentation and release notes are available at [Multiplayer Documen

### Changed

### Removed

- Removed `com.unity.modules.animation`, `com.unity.modules.physics` and `com.unity.modules.physics2d` dependencies from the package (#1812)

### Fixed

- Fixed user never being notified in the editor that a NetworkBehaviour requires a NetworkObject to function properly. (#1808)
Expand Down
2 changes: 2 additions & 0 deletions com.unity.netcode.gameobjects/Components/NetworkAnimator.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#if COM_UNITY_MODULES_ANIMATION
using Unity.Collections;
using Unity.Collections.LowLevel.Unsafe;
using UnityEngine;
Expand Down Expand Up @@ -427,3 +428,4 @@ public void ResetTrigger(int hash)
}
}
}
#endif // COM_UNITY_MODULES_ANIMATION
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#if COM_UNITY_MODULES_PHYSICS
using UnityEngine;

namespace Unity.Netcode.Components
Expand Down Expand Up @@ -78,3 +79,4 @@ public override void OnNetworkDespawn()
}
}
}
#endif // COM_UNITY_MODULES_PHYSICS
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#if COM_UNITY_MODULES_PHYSICS2D
using UnityEngine;

namespace Unity.Netcode.Components
Expand Down Expand Up @@ -78,3 +79,4 @@ public override void OnNetworkDespawn()
}
}
}
#endif // COM_UNITY_MODULES_PHYSICS2D
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,22 @@
"Unity.Netcode.Runtime",
"Unity.Collections"
],
"allowUnsafeCode": true
"allowUnsafeCode": true,
"versionDefines": [
{
"name": "com.unity.modules.animation",
"expression": "",
"define": "COM_UNITY_MODULES_ANIMATION"
},
{
"name": "com.unity.modules.physics",
"expression": "",
"define": "COM_UNITY_MODULES_PHYSICS"
},
{
"name": "com.unity.modules.physics2d",
"expression": "",
"define": "COM_UNITY_MODULES_PHYSICS2D"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -112,19 +112,23 @@ public override void OnInspectorGUI()
EditorGUILayout.PropertyField(m_InLocalSpaceProperty);
EditorGUILayout.PropertyField(m_InterpolateProperty);

#if COM_UNITY_MODULES_PHYSICS
// if rigidbody is present but network rigidbody is not present
var go = ((NetworkTransform)target).gameObject;
if (go.TryGetComponent<Rigidbody>(out _) && go.TryGetComponent<NetworkRigidbody>(out _) == false)
{
EditorGUILayout.HelpBox("This GameObject contains a Rigidbody but no NetworkRigidbody.\n" +
"Add a NetworkRigidbody component to improve Rigidbody synchronization.", MessageType.Warning);
}
#endif // COM_UNITY_MODULES_PHYSICS

#if COM_UNITY_MODULES_PHYSICS2D
if (go.TryGetComponent<Rigidbody2D>(out _) && go.TryGetComponent<NetworkRigidbody2D>(out _) == false)
{
EditorGUILayout.HelpBox("This GameObject contains a Rigidbody2D but no NetworkRigidbody2D.\n" +
"Add a NetworkRigidbody2D component to improve Rigidbody2D synchronization.", MessageType.Warning);
}
#endif // COM_UNITY_MODULES_PHYSICS2D

serializedObject.ApplyModifiedProperties();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#if COM_UNITY_MODULES_ANIMATION
using System.Collections;
using System.Collections.Generic;
using NUnit.Framework;
Expand Down Expand Up @@ -235,3 +236,4 @@ public IEnumerator AnimationStateSyncTestWithOverride()
}
}
}
#endif // COM_UNITY_MODULES_ANIMATION
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#if COM_UNITY_MODULES_PHYSICS2D
using System.Collections;
using NUnit.Framework;
using Unity.Netcode.Components;
Expand Down Expand Up @@ -76,3 +77,4 @@ public IEnumerator TestRigidbodyKinematicEnableDisable()
}
}
}
#endif // COM_UNITY_MODULES_PHYSICS2D
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#if COM_UNITY_MODULES_PHYSICS
using System.Collections;
using NUnit.Framework;
using Unity.Netcode.Components;
Expand Down Expand Up @@ -75,3 +76,4 @@ public IEnumerator TestRigidbodyKinematicEnableDisable()
}
}
}
#endif // COM_UNITY_MODULES_PHYSICS
3 changes: 0 additions & 3 deletions com.unity.netcode.gameobjects/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
"version": "1.0.0-pre.6",
"unity": "2020.3",
"dependencies": {
"com.unity.modules.animation": "1.0.0",
"com.unity.modules.physics": "1.0.0",
"com.unity.modules.physics2d": "1.0.0",
Comment on lines -8 to -10
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this feels so good, isn't it? :)

"com.unity.nuget.mono-cecil": "1.10.1",
"com.unity.collections": "1.1.0"
}
Expand Down
21 changes: 0 additions & 21 deletions minimalproject/Packages/packages-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@
"depth": 0,
"source": "local",
"dependencies": {
"com.unity.modules.animation": "1.0.0",
"com.unity.modules.physics": "1.0.0",
"com.unity.modules.physics2d": "1.0.0",
"com.unity.nuget.mono-cecil": "1.10.1",
"com.unity.collections": "1.1.0"
}
Expand All @@ -63,12 +60,6 @@
},
"url": "https://packages.unity.com"
},
"com.unity.modules.animation": {
"version": "1.0.0",
"depth": 1,
"source": "builtin",
"dependencies": {}
},
"com.unity.modules.imgui": {
"version": "1.0.0",
"depth": 3,
Expand All @@ -80,18 +71,6 @@
"depth": 3,
"source": "builtin",
"dependencies": {}
},
"com.unity.modules.physics": {
"version": "1.0.0",
"depth": 1,
"source": "builtin",
"dependencies": {}
},
"com.unity.modules.physics2d": {
"version": "1.0.0",
"depth": 1,
"source": "builtin",
"dependencies": {}
}
}
}
9 changes: 3 additions & 6 deletions testproject/Packages/packages-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,15 @@
"depth": 0,
"source": "local",
"dependencies": {
"com.unity.netcode.gameobjects": "1.0.0-pre.5",
"com.unity.transport": "1.0.0-pre.13"
"com.unity.netcode.gameobjects": "1.0.0-pre.6",
"com.unity.transport": "1.0.0-pre.15"
}
},
"com.unity.netcode.gameobjects": {
"version": "file:../../com.unity.netcode.gameobjects",
"depth": 0,
"source": "local",
"dependencies": {
"com.unity.modules.animation": "1.0.0",
"com.unity.modules.physics": "1.0.0",
"com.unity.modules.physics2d": "1.0.0",
"com.unity.nuget.mono-cecil": "1.10.1",
"com.unity.collections": "1.1.0"
}
Expand Down Expand Up @@ -188,7 +185,7 @@
"url": "https://packages.unity.com"
},
"com.unity.transport": {
"version": "1.0.0-pre.13",
"version": "1.0.0-pre.15",
"depth": 1,
"source": "registry",
"dependencies": {
Expand Down