This is just like the RaycastNonAlloc() functions from Unity, all with the same physics 2D cast processing, same parameters and same return type. The differences are only:
It draws a visualization for the cast
It adds 3 optional parameters to the end of the function signatures that only affect the visualization (namely "nameTag", "durationInSec" and "hiddenByNearerObjects")
You can just change the class prefix from existing code like "Physics2D.RaycastNonAlloc()" becomes "DrawPhysics2D.RaycastNonAlloc()" and it will work as before, but with the added visualization. In builds the visualization can be omitted by setting UsedUnityLineDrawingMethod to "disabled", but the cast and the returned function results will still work.
Note: This function has "NonAlloc" in its name to be consistent with the function names of the UnityEnigne.Physics class, but despite the version from UnityEnigne.Physics this function here in DrawXXL.DrawPhysics may allocate small amounts of memory garbage due to generation of the text description that gets displayed in the Scene view together with the cast visualisation.
Green parameters are required. Yellow parameters are optional, but have to be supplied in order.
static int DrawPhysics2D.RaycastNonAlloc(...);
Code snippet names: drawRaycastNonAlloc2D and drawRaycastNonAlloc2D_func.
Parameters:
Type
Parameter Name
Description
Vector2
origin
Vector2
direction
RaycastHit2D[]
results
float
distance
int
layerMask
float
minDepth
float
maxDepth
string
nameTag
float
durationInSec
The duration in seconds how long the drawn thing stays visible. The default value of 0 means that it stays only during the current Update frame. Instead of using this parameter you can also overwrite him with a global setting so you don't always have to supply all other preceding function parameters till you reach this late parameter.
bool
hiddenByNearerObjects
This specifies if the drawn thing will get hidden if other geometry is in front of it or if it shines through. It is the same as the depthTest parameter of Unitys Debug.DrawLine(). Not all drawing methods support toggling this in the same way. For some methods the lines are fully hidden, for others the hidden lines shimmer through. Instead of using this parameter you can also overwrite him with a global setting so you don't always have to supply all other preceding function parameters till you reach this late parameter.