Regarding camera assignment and the code example referenced here:
ALINE Documentation – Advanced Cameras
The example provided in the documentation allocates a new array every frame within Update
. To optimize this, I switched to using a preallocated array (_CameraTargets
) and simply update its first element each frame, like so:
_CameraTargets[0] = InputManager.Instance.CurrentCamera;
However, this change causes the assignment to draw.cameraTargets
to silently fail. After the line:
draw.cameraTargets = _CameraTargets;
draw.cameraTargets
remains null
.
Here’s the full snippet for context:
_CameraTargets[0] = InputManager.Instance.CurrentCamera;
var draw = DrawingManager.GetBuilder(true);
draw.cameraTargets = _CameraTargets;
using (draw.WithMatrix(matrix))
using (draw.WithLineWidth(LineWidth, IsAutomaticJoinsEnabled))
{
if (IsSolidEnabled)
draw.SolidBox(LocalPosition, Quaternion.identity, 1.0f, FillColor);
draw.WireBox(LocalPosition, Quaternion.identity, 1.0f, LineColor);
}
draw.Dispose();
Is there an internal check that prevents the cameraTargets assignment if the array is reused or modified externally? Or is there a required step to force the DrawingManager
to recognize updated values in a persistent array?