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
}

0 commit comments

Comments
 (0)