Skip to content

Commit 13f138f

Browse files
committed
Fixes a build issue
Fixes #4
1 parent a6a79c1 commit 13f138f

28 files changed

+146
-70
lines changed

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
![Banner](./Gifs~/banner.png)
1+
/![Banner](./Gifs~/banner.png)
22

33
This asset allows users to view raycasts as the user fires them.
44

@@ -14,6 +14,15 @@ To get a visual to show up for a physics call simply do the following:
1414
- Replace `Physics2D.` with `VisualPhysics2D.`.
1515
- Some 2D functions rely more on a 3D perspective in the editor depending on the orientation of the casts.
1616

17+
```csharp
18+
// Example
19+
void SomeFunction() {
20+
if (VisualPhysics.Raycast(position, direction)) {
21+
Debug.Log("Hit!");
22+
}
23+
}
24+
```
25+
1726
## Installation
1827
#### Using Unity Package Manager
1928
1. Open the Package Manager from `Window/Package Manager`

Runtime/2D/BoxCast.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ public static int BoxCast(
200200

201201
[MethodImpl(MethodImplOptions.AggressiveInlining)]
202202
internal static void DrawBox(Vector2 origin, Vector2 size, float angle, Vector2 direction, float distance, in RaycastHit2D hit, ContactFilter2D? contactFilter = default) {
203+
#if UNITY_EDITOR
203204
size *= 0.5f;
204205

205206
direction.Normalize();
@@ -269,6 +270,7 @@ internal static void DrawBox(Vector2 origin, Vector2 size, float angle, Vector2
269270
filter = contactFilter.Value
270271
};
271272
filter.Draw(VisualUtils.GetDefaultColor());
273+
#endif
272274
}
273275
}
274276
}

Runtime/2D/CapsuleCast.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ public static int CapsuleCast(
217217
[MethodImpl(MethodImplOptions.AggressiveInlining)]
218218
internal static void DrawCapsule(Vector2 origin, Vector2 size, float angle, CapsuleDirection2D capsuleDirection,
219219
Vector2 direction, float distance, in RaycastHit2D hit, ContactFilter2D? contactFilter = default) {
220+
#if UNITY_EDITOR
220221
direction.Normalize();
221222
bool didHit = hit.collider;
222223
Color color = VisualUtils.GetColor(didHit);
@@ -296,6 +297,7 @@ internal static void DrawCapsule(Vector2 origin, Vector2 size, float angle, Caps
296297
};
297298

298299
filter.Draw(VisualUtils.GetDefaultColor());
300+
#endif
299301
}
300302
}
301303
}

Runtime/2D/CircleCast.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ public static int CircleCast(
194194

195195
[MethodImpl(MethodImplOptions.AggressiveInlining)]
196196
internal static void DrawCircle(Vector2 origin, float radius, Vector2 direction, float distance, in RaycastHit2D hit, ContactFilter2D? contactFilter = default) {
197+
#if UNITY_EDITOR
197198
direction.Normalize();
198199
bool didHit = hit.collider;
199200
Color color = VisualUtils.GetColor(didHit);
@@ -260,6 +261,7 @@ internal static void DrawCircle(Vector2 origin, float radius, Vector2 direction,
260261
};
261262

262263
filter.Draw(VisualUtils.GetDefaultColor());
264+
#endif
263265
}
264266
}
265267
}

Runtime/2D/GetContacts.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ public static int GetContacts(
243243

244244
[MethodImpl(MethodImplOptions.AggressiveInlining)]
245245
internal static void DrawContact(ContactPoint2D contactPoint, ContactFilter2D? contactFilter = default) {
246+
#if UNITY_EDITOR
246247
Color color = VisualUtils.GetDefaultColor();
247248

248249
Circle circle = Circle.Default;
@@ -259,10 +260,12 @@ internal static void DrawContact(ContactPoint2D contactPoint, ContactFilter2D? c
259260
filter = contactFilter.Value
260261
};
261262
filter.Draw(color);
263+
#endif
262264
}
263265

264266
[MethodImpl(MethodImplOptions.AggressiveInlining)]
265267
internal static void DrawContact(Collider2D from, Collider2D to, ContactFilter2D? contactFilter = default) {
268+
#if UNITY_EDITOR
266269
Color color = VisualUtils.GetDefaultColor();
267270

268271
Line line = new Line {
@@ -281,10 +284,12 @@ internal static void DrawContact(Collider2D from, Collider2D to, ContactFilter2D
281284
filter = contactFilter.Value
282285
};
283286
filter.Draw(color);
287+
#endif
284288
}
285289

286290
[MethodImpl(MethodImplOptions.AggressiveInlining)]
287291
internal static void DrawContact(Rigidbody2D from, Collider2D to, ContactFilter2D? contactFilter = default) {
292+
#if UNITY_EDITOR
288293
Color color = VisualUtils.GetDefaultColor();
289294

290295
Line line = new Line {
@@ -303,6 +308,7 @@ internal static void DrawContact(Rigidbody2D from, Collider2D to, ContactFilter2
303308
filter = contactFilter.Value
304309
};
305310
filter.Draw(color);
311+
#endif
306312
}
307313
}
308314
}

Runtime/2D/GetRayIntersection.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ public static RaycastHit2D GetRayIntersection(
5353

5454
[MethodImpl(MethodImplOptions.AggressiveInlining)]
5555
internal static void DrawRayIntersection(in Ray ray, in RaycastHit2D hit, float distance) {
56+
#if UNITY_EDITOR
5657
bool didHit = hit.collider;
5758
Color color = VisualUtils.GetColor(didHit);
5859

@@ -81,6 +82,7 @@ internal static void DrawRayIntersection(in Ray ray, in RaycastHit2D hit, float
8182
arrow.direction = ray.direction.normalized * VisualUtils.GetMaxRayLength(distance);
8283
arrow.Draw(color);
8384
}
85+
#endif
8486
}
8587
}
8688
}

Runtime/2D/LineCast.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ public static int Linecast(
126126
}
127127

128128
internal static void DrawLine(Vector2 start, Vector2 end, in RaycastHit2D hit, ContactFilter2D? contactFilter = default) {
129+
#if UNITY_EDITOR
129130
bool didHit = hit.collider;
130131
Color color = VisualUtils.GetColor(didHit);
131132

@@ -181,6 +182,7 @@ internal static void DrawLine(Vector2 start, Vector2 end, in RaycastHit2D hit, C
181182
filter = contactFilter.Value
182183
};
183184
filter.Draw(VisualUtils.GetDefaultColor());
185+
#endif
184186
}
185187
}
186188
}

Runtime/2D/OverlapArea.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ public static int OverlapArea(
130130
}
131131

132132
internal static void DrawArea(Vector2 a, Vector2 b, Collider2D collider, ContactFilter2D? contactFilter = default) {
133+
#if UNITY_EDITOR
133134
bool didHit = collider;
134135
Color color = VisualUtils.GetColor(didHit);
135136

@@ -166,6 +167,7 @@ internal static void DrawArea(Vector2 a, Vector2 b, Collider2D collider, Contact
166167
};
167168

168169
filter.Draw(VisualUtils.GetDefaultColor());
170+
#endif
169171
}
170172
}
171173
}

Runtime/2D/OverlapBox.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ public static int OverlapBox(
141141

142142
[MethodImpl(MethodImplOptions.AggressiveInlining)]
143143
internal static void DrawBoxStationary(Vector2 origin, Vector2 size, float angle, Collider2D collider, ContactFilter2D? contactFilter = default) {
144+
#if UNITY_EDITOR
144145
size *= 0.5f;
145146

146147
bool didHit = collider;
@@ -177,6 +178,7 @@ internal static void DrawBoxStationary(Vector2 origin, Vector2 size, float angle
177178
filter = contactFilter.Value
178179
};
179180
filter.Draw(VisualUtils.GetDefaultColor());
181+
#endif
180182
}
181183
}
182184
}

Runtime/2D/OverlapCapsule.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ public static int OverlapCapsule(
151151
}
152152

153153
internal static void DrawCapsuleStationary(Vector2 origin, Vector2 size, CapsuleDirection2D direction, float angle, Collider2D collider, ContactFilter2D? contactFilter = default) {
154+
#if UNITY_EDITOR
154155
bool didHit = collider;
155156
Color color = VisualUtils.GetColor(didHit);
156157

@@ -196,6 +197,7 @@ internal static void DrawCapsuleStationary(Vector2 origin, Vector2 size, Capsule
196197
};
197198

198199
filter.Draw(VisualUtils.GetDefaultColor());
200+
#endif
199201
}
200202
}
201203
}

0 commit comments

Comments
 (0)