Skip to content

Commit 6e69c6e

Browse files
authored
refactor: remove animation, physics and physics2d dependencies (#1812)
1 parent 6695fbc commit 6e69c6e

File tree

12 files changed

+41
-31
lines changed

12 files changed

+41
-31
lines changed

com.unity.netcode.gameobjects/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ Additional documentation and release notes are available at [Multiplayer Documen
1414

1515
### Changed
1616

17+
### Removed
18+
19+
- Removed `com.unity.modules.animation`, `com.unity.modules.physics` and `com.unity.modules.physics2d` dependencies from the package (#1812)
20+
1721
### Fixed
1822

1923
- Fixed user never being notified in the editor that a NetworkBehaviour requires a NetworkObject to function properly. (#1808)

com.unity.netcode.gameobjects/Components/NetworkAnimator.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#if COM_UNITY_MODULES_ANIMATION
12
using Unity.Collections;
23
using Unity.Collections.LowLevel.Unsafe;
34
using UnityEngine;
@@ -427,3 +428,4 @@ public void ResetTrigger(int hash)
427428
}
428429
}
429430
}
431+
#endif // COM_UNITY_MODULES_ANIMATION

com.unity.netcode.gameobjects/Components/NetworkRigidbody.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#if COM_UNITY_MODULES_PHYSICS
12
using UnityEngine;
23

34
namespace Unity.Netcode.Components
@@ -78,3 +79,4 @@ public override void OnNetworkDespawn()
7879
}
7980
}
8081
}
82+
#endif // COM_UNITY_MODULES_PHYSICS

com.unity.netcode.gameobjects/Components/NetworkRigidbody2D.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#if COM_UNITY_MODULES_PHYSICS2D
12
using UnityEngine;
23

34
namespace Unity.Netcode.Components
@@ -78,3 +79,4 @@ public override void OnNetworkDespawn()
7879
}
7980
}
8081
}
82+
#endif // COM_UNITY_MODULES_PHYSICS2D

com.unity.netcode.gameobjects/Components/com.unity.netcode.components.asmdef

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,22 @@
55
"Unity.Netcode.Runtime",
66
"Unity.Collections"
77
],
8-
"allowUnsafeCode": true
8+
"allowUnsafeCode": true,
9+
"versionDefines": [
10+
{
11+
"name": "com.unity.modules.animation",
12+
"expression": "",
13+
"define": "COM_UNITY_MODULES_ANIMATION"
14+
},
15+
{
16+
"name": "com.unity.modules.physics",
17+
"expression": "",
18+
"define": "COM_UNITY_MODULES_PHYSICS"
19+
},
20+
{
21+
"name": "com.unity.modules.physics2d",
22+
"expression": "",
23+
"define": "COM_UNITY_MODULES_PHYSICS2D"
24+
}
25+
]
926
}

com.unity.netcode.gameobjects/Editor/NetworkTransformEditor.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,19 +112,23 @@ public override void OnInspectorGUI()
112112
EditorGUILayout.PropertyField(m_InLocalSpaceProperty);
113113
EditorGUILayout.PropertyField(m_InterpolateProperty);
114114

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

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

129133
serializedObject.ApplyModifiedProperties();
130134
}

com.unity.netcode.gameobjects/Tests/Runtime/NetworkAnimator/NetworkAnimatorTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#if COM_UNITY_MODULES_ANIMATION
12
using System.Collections;
23
using System.Collections.Generic;
34
using NUnit.Framework;
@@ -235,3 +236,4 @@ public IEnumerator AnimationStateSyncTestWithOverride()
235236
}
236237
}
237238
}
239+
#endif // COM_UNITY_MODULES_ANIMATION

com.unity.netcode.gameobjects/Tests/Runtime/Physics/NetworkRigidbody2DTest.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#if COM_UNITY_MODULES_PHYSICS2D
12
using System.Collections;
23
using NUnit.Framework;
34
using Unity.Netcode.Components;
@@ -76,3 +77,4 @@ public IEnumerator TestRigidbodyKinematicEnableDisable()
7677
}
7778
}
7879
}
80+
#endif // COM_UNITY_MODULES_PHYSICS2D

com.unity.netcode.gameobjects/Tests/Runtime/Physics/NetworkRigidbodyTest.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#if COM_UNITY_MODULES_PHYSICS
12
using System.Collections;
23
using NUnit.Framework;
34
using Unity.Netcode.Components;
@@ -75,3 +76,4 @@ public IEnumerator TestRigidbodyKinematicEnableDisable()
7576
}
7677
}
7778
}
79+
#endif // COM_UNITY_MODULES_PHYSICS

com.unity.netcode.gameobjects/package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55
"version": "1.0.0-pre.6",
66
"unity": "2020.3",
77
"dependencies": {
8-
"com.unity.modules.animation": "1.0.0",
9-
"com.unity.modules.physics": "1.0.0",
10-
"com.unity.modules.physics2d": "1.0.0",
118
"com.unity.nuget.mono-cecil": "1.10.1",
129
"com.unity.collections": "1.1.0"
1310
}

minimalproject/Packages/packages-lock.json

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@
3838
"depth": 0,
3939
"source": "local",
4040
"dependencies": {
41-
"com.unity.modules.animation": "1.0.0",
42-
"com.unity.modules.physics": "1.0.0",
43-
"com.unity.modules.physics2d": "1.0.0",
4441
"com.unity.nuget.mono-cecil": "1.10.1",
4542
"com.unity.collections": "1.1.0"
4643
}
@@ -63,12 +60,6 @@
6360
},
6461
"url": "https://packages.unity.com"
6562
},
66-
"com.unity.modules.animation": {
67-
"version": "1.0.0",
68-
"depth": 1,
69-
"source": "builtin",
70-
"dependencies": {}
71-
},
7263
"com.unity.modules.imgui": {
7364
"version": "1.0.0",
7465
"depth": 3,
@@ -80,18 +71,6 @@
8071
"depth": 3,
8172
"source": "builtin",
8273
"dependencies": {}
83-
},
84-
"com.unity.modules.physics": {
85-
"version": "1.0.0",
86-
"depth": 1,
87-
"source": "builtin",
88-
"dependencies": {}
89-
},
90-
"com.unity.modules.physics2d": {
91-
"version": "1.0.0",
92-
"depth": 1,
93-
"source": "builtin",
94-
"dependencies": {}
9574
}
9675
}
9776
}

testproject/Packages/packages-lock.json

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,18 +70,15 @@
7070
"depth": 0,
7171
"source": "local",
7272
"dependencies": {
73-
"com.unity.netcode.gameobjects": "1.0.0-pre.5",
74-
"com.unity.transport": "1.0.0-pre.13"
73+
"com.unity.netcode.gameobjects": "1.0.0-pre.6",
74+
"com.unity.transport": "1.0.0-pre.15"
7575
}
7676
},
7777
"com.unity.netcode.gameobjects": {
7878
"version": "file:../../com.unity.netcode.gameobjects",
7979
"depth": 0,
8080
"source": "local",
8181
"dependencies": {
82-
"com.unity.modules.animation": "1.0.0",
83-
"com.unity.modules.physics": "1.0.0",
84-
"com.unity.modules.physics2d": "1.0.0",
8582
"com.unity.nuget.mono-cecil": "1.10.1",
8683
"com.unity.collections": "1.1.0"
8784
}
@@ -188,7 +185,7 @@
188185
"url": "https://packages.unity.com"
189186
},
190187
"com.unity.transport": {
191-
"version": "1.0.0-pre.13",
188+
"version": "1.0.0-pre.15",
192189
"depth": 1,
193190
"source": "registry",
194191
"dependencies": {

0 commit comments

Comments
 (0)