Skip to content

Commit 46f6570

Browse files
committed
remove unnecessary defines.
1 parent b44f5ce commit 46f6570

10 files changed

+37
-76
lines changed

com.unity.ml-agents/Editor/RayPerceptionSensorComponentBaseEditor.cs

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
#if MLA_UNITY_PHYSICS_MODULE || !UNITY_2019_4_OR_NEWER
2-
#define MLA_UNITY_PHYSICS_MODULE_ENABLED
3-
#endif
4-
5-
#if MLA_UNITY_PHYSICS2D_MODULE || !UNITY_2019_4_OR_NEWER
6-
#define MLA_UNITY_PHYSICS2D_MODULE_ENABLED
7-
#endif
8-
91
using UnityEngine;
102
using UnityEditor;
113
using Unity.MLAgents.Sensors;
@@ -18,19 +10,19 @@ internal class RayPerceptionSensorComponentBaseEditor : UnityEditor.Editor
1810

1911
protected void OnRayPerceptionInspectorGUI(bool is3d)
2012
{
21-
#if !MLA_UNITY_PHYSICS_MODULE_ENABLED
13+
#if !MLA_UNITY_PHYSICS_MODULE
2214
if (is3d)
2315
{
24-
EditorGUILayout.HelpBox("The Physics Module is not currently present. "+
25-
"Please add it to your project in order to use the Ray Perception APIs in the "+
16+
EditorGUILayout.HelpBox("The Physics Module is not currently present. " +
17+
"Please add it to your project in order to use the Ray Perception APIs in the " +
2618
$"{nameof(RayPerceptionSensorComponent3D)}", MessageType.Warning);
2719
}
2820
#endif
29-
#if !MLA_UNITY_PHYSICS2D_MODULE_ENABLED
21+
#if !MLA_UNITY_PHYSICS2D_MODULE
3022
if (!is3d)
3123
{
32-
EditorGUILayout.HelpBox("The Physics2D Module is not currently present. "+
33-
"Please add it to your project in order to use the Ray Perception APIs in the "+
24+
EditorGUILayout.HelpBox("The Physics2D Module is not currently present. " +
25+
"Please add it to your project in order to use the Ray Perception APIs in the " +
3426
$"{nameof(RayPerceptionSensorComponent3D)}", MessageType.Warning);
3527
}
3628
#endif

com.unity.ml-agents/Runtime/Analytics/InferenceAnalytics.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,6 @@ static bool EnableAnalytics()
7373
s_EventRegistered = false;
7474
#endif
7575
return s_EventRegistered;
76-
#else // no editor, no analytics
77-
return false;
78-
#endif
7976
}
8077

8178
public static bool IsAnalyticsEnabled()

com.unity.ml-agents/Runtime/Sensors/RayPerceptionSensor.cs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
#if MLA_UNITY_PHYSICS_MODULE || !UNITY_2019_4_OR_NEWER
2-
#define MLA_UNITY_PHYSICS_MODULE_ENABLED
3-
#endif
4-
5-
#if MLA_UNITY_PHYSICS2D_MODULE || !UNITY_2019_4_OR_NEWER
6-
#define MLA_UNITY_PHYSICS2D_MODULE_ENABLED
7-
#endif
8-
91
using System;
102
using System.Collections.Generic;
113
using UnityEngine;
@@ -436,7 +428,7 @@ out DebugDisplayInfo.RayInfo debugRayOut
436428

437429
if (input.CastType == RayPerceptionCastType.Cast3D)
438430
{
439-
#if MLA_UNITY_PHYSICS_MODULE_ENABLED
431+
#if MLA_UNITY_PHYSICS_MODULE
440432
RaycastHit rayHit;
441433
if (scaledCastRadius > 0f)
442434
{
@@ -457,7 +449,7 @@ out DebugDisplayInfo.RayInfo debugRayOut
457449
}
458450
else
459451
{
460-
#if MLA_UNITY_PHYSICS2D_MODULE_ENABLED
452+
#if MLA_UNITY_PHYSICS2D_MODULE
461453
RaycastHit2D rayHit;
462454
if (scaledCastRadius > 0f)
463455
{

com.unity.ml-agents/Runtime/Sensors/RayPerceptionSensorComponent2D.cs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
#if MLA_UNITY_PHYSICS_MODULE || !UNITY_2019_4_OR_NEWER
2-
#define MLA_UNITY_PHYSICS_MODULE_ENABLED
3-
#endif
4-
5-
#if MLA_UNITY_PHYSICS2D_MODULE || !UNITY_2019_4_OR_NEWER
6-
#define MLA_UNITY_PHYSICS2D_MODULE_ENABLED
7-
#endif
8-
91
using UnityEngine;
102

113
namespace Unity.MLAgents.Sensors
@@ -22,11 +14,7 @@ public class RayPerceptionSensorComponent2D : RayPerceptionSensorComponentBase
2214
public RayPerceptionSensorComponent2D()
2315
{
2416
// Set to the 2D defaults (just in case they ever diverge).
25-
#if MLA_UNITY_PHYSICS2D_MODULE_ENABLED
26-
RayLayerMask = Physics2D.DefaultRaycastLayers;
27-
#else
2817
RayLayerMask = -5;
29-
#endif
3018
}
3119

3220
/// <inheritdoc/>

com.unity.ml-agents/Runtime/Sensors/RayPerceptionSensorComponent3D.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
#if MLA_UNITY_PHYSICS_MODULE || !UNITY_2019_4_OR_NEWER
2-
#define MLA_UNITY_PHYSICS_MODULE_ENABLED
3-
#endif
4-
5-
#if MLA_UNITY_PHYSICS2D_MODULE || !UNITY_2019_4_OR_NEWER
6-
#define MLA_UNITY_PHYSICS2D_MODULE_ENABLED
7-
#endif
8-
91
using UnityEngine;
102
using UnityEngine.Serialization;
113

com.unity.ml-agents/Runtime/Sensors/RayPerceptionSensorComponentBase.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
#if MLA_UNITY_PHYSICS_MODULE || !UNITY_2019_4_OR_NEWER
2-
#define MLA_UNITY_PHYSICS_MODULE_ENABLED
3-
#endif
4-
5-
#if MLA_UNITY_PHYSICS2D_MODULE || !UNITY_2019_4_OR_NEWER
6-
#define MLA_UNITY_PHYSICS2D_MODULE_ENABLED
7-
#endif
8-
91
using System;
102
using System.Collections.Generic;
113
using UnityEngine;

com.unity.ml-agents/Tests/Editor/PublicAPI/PublicApiValidation.cs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
#if MLA_UNITY_PHYSICS_MODULE || !UNITY_2019_4_OR_NEWER
2-
#define MLA_UNITY_PHYSICS_MODULE_ENABLED
3-
#endif
4-
5-
#if MLA_UNITY_PHYSICS2D_MODULE || !UNITY_2019_4_OR_NEWER
6-
#define MLA_UNITY_PHYSICS2D_MODULE_ENABLED
7-
#endif
8-
91
using System.Collections.Generic;
102
using Unity.MLAgents.Sensors;
113
using NUnit.Framework;
@@ -61,7 +53,7 @@ public void CheckSetupRenderTextureSensorComponent()
6153
Assert.IsTrue(sensorComponent.Grayscale);
6254
}
6355

64-
#if MLA_UNITY_PHYSICS_MODULE_ENABLED
56+
#if MLA_UNITY_PHYSICS_MODULE
6557
[Test]
6658
public void CheckSetupRayPerceptionSensorComponent()
6759
{

com.unity.ml-agents/Tests/Runtime/Sensor/RayPerceptionSensorTests.cs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,9 @@
1-
#if MLA_UNITY_PHYSICS_MODULE || !UNITY_2019_4_OR_NEWER
2-
#define MLA_UNITY_PHYSICS_MODULE_ENABLED
3-
#endif
4-
5-
#if MLA_UNITY_PHYSICS2D_MODULE || !UNITY_2019_4_OR_NEWER
6-
#define MLA_UNITY_PHYSICS2D_MODULE_ENABLED
7-
#endif
8-
91
using System;
102
using System.Collections.Generic;
113
using NUnit.Framework;
124
using UnityEngine;
13-
using UnityEngine.TestTools;
145
using Unity.MLAgents.Sensors;
6+
using UnityEngine.TestTools;
157

168
namespace Unity.MLAgents.Tests
179
{
@@ -35,15 +27,15 @@ public class RayPerception3DTests
3527
[Test]
3628
public void TestDefaultLayersAreNegativeFive()
3729
{
38-
#if MLA_UNITY_PHYSICS_MODULE_ENABLED
30+
#if MLA_UNITY_PHYSICS_MODULE
3931
Assert.IsTrue(Physics.DefaultRaycastLayers == -5);
4032
#endif
41-
#if MLA_UNITY_PHYSICS2D_MODULE_ENABLED
33+
#if MLA_UNITY_PHYSICS2D_MODULE
4234
Assert.IsTrue(Physics2D.DefaultRaycastLayers == -5);
4335
#endif
4436
}
4537

46-
#if MLA_UNITY_PHYSICS_MODULE_ENABLED
38+
#if MLA_UNITY_PHYSICS_MODULE
4739
// Use built-in tags
4840
const string k_CubeTag = "Player";
4941
const string k_SphereTag = "Respawn";

com.unity.ml-agents/Tests/Runtime/Sensor/Unity.ML-Agents.Runtime.Sensor.Tests.asmdef

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,17 @@
2121
"autoReferenced": false,
2222
"defineConstraints": [
2323
"UNITY_INCLUDE_TESTS"
24+
],
25+
"versionDefines": [
26+
{
27+
"name": "com.unity.modules.physics",
28+
"expression": "1.0.0",
29+
"define": "MLA_UNITY_PHYSICS_MODULE"
30+
},
31+
{
32+
"name": "com.unity.modules.physics2d",
33+
"expression": "1.0.0",
34+
"define": "MLA_UNITY_PHYSICS2D_MODULE"
35+
}
2436
]
2537
}

com.unity.ml-agents/Tests/Runtime/Unity.ML-Agents.Runtime.Tests.asmdef

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,17 @@
2121
"autoReferenced": false,
2222
"defineConstraints": [
2323
"UNITY_INCLUDE_TESTS"
24+
],
25+
"versionDefines": [
26+
{
27+
"name": "com.unity.modules.physics",
28+
"expression": "1.0.0",
29+
"define": "MLA_UNITY_PHYSICS_MODULE"
30+
},
31+
{
32+
"name": "com.unity.modules.physics2d",
33+
"expression": "1.0.0",
34+
"define": "MLA_UNITY_PHYSICS2D_MODULE"
35+
}
2436
]
2537
}

0 commit comments

Comments
 (0)