-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
362 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+0 Bytes
(100%)
Megumin.UnityPackage/Packages/megumin.explosion4unity/Plugins/Megumin.Explosion.dll
Binary file not shown.
Binary file modified
BIN
-4 Bytes
(100%)
Megumin.UnityPackage/Packages/megumin.explosion4unity/Plugins/Megumin.Explosion.pdb
Binary file not shown.
212 changes: 106 additions & 106 deletions
212
Megumin.UnityPackage/Packages/megumin.explosion4unity/Plugins/Megumin.Explosion.xml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
76 changes: 76 additions & 0 deletions
76
....UnityPackage/Packages/megumin.explosion4unity/Runtime/Scripts/NewClass/MouseRayPicker.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
using UnityEngine.InputSystem; | ||
|
||
namespace Megumin | ||
{ | ||
public abstract class MouseRayPicker<T> : MonoBehaviour | ||
{ | ||
public float maxDistance = float.PositiveInfinity; | ||
public GameObjectFilter filter; | ||
public LayerMask LayerMask = -5; | ||
public Camera Camera; | ||
|
||
public bool TryPick(out T result) | ||
{ | ||
return TryPick(out result, out var _, out var _); | ||
} | ||
|
||
public bool TryPick(out T result, out Ray ray, out RaycastHit hitInfo) | ||
{ | ||
if (!Camera) | ||
{ | ||
Camera = Camera.main; | ||
} | ||
|
||
return TryPick(out result, Camera, out ray, out hitInfo); | ||
} | ||
|
||
public bool TryPick(out T result, Camera camera, out Ray ray, out RaycastHit hitInfo) | ||
{ | ||
if (!camera) | ||
{ | ||
result = default; | ||
ray = default; | ||
hitInfo = default; | ||
return false; | ||
} | ||
|
||
ray = camera.MouseRay(); | ||
return ray.TryPick(out result, out hitInfo, maxDistance, LayerMask, filter); | ||
} | ||
|
||
|
||
public bool TryPickAll(List<T> results) | ||
{ | ||
return TryPickAll(results, out var _); | ||
} | ||
|
||
public bool TryPickAll(List<T> results, out Ray ray) | ||
{ | ||
if (!Camera) | ||
{ | ||
Camera = Camera.main; | ||
} | ||
|
||
return TryPickAll(results, Camera, out ray); | ||
} | ||
|
||
public bool TryPickAll(List<T> results, Camera camera, out Ray ray) | ||
{ | ||
if (!camera) | ||
{ | ||
ray = default; | ||
return false; | ||
} | ||
|
||
ray = camera.MouseRay(); | ||
return ray.TryPickAll(results, maxDistance, LayerMask, filter); | ||
} | ||
} | ||
|
||
|
||
} | ||
|
||
|
2 changes: 2 additions & 0 deletions
2
...yPackage/Packages/megumin.explosion4unity/Runtime/Scripts/NewClass/MouseRayPicker.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.