Files
XericLibrary-WebGL-Publish/Runtime/DrawDebugLibrary/components/screenspace/CameraGridVisualizer.cs
T
2026-07-06 08:47:33 +08:00

38 lines
1.6 KiB
C#

namespace DrawXXL
{
using UnityEngine;
[HelpURL("https://www.symphonygames.net/drawxxldocumentation/index.html")]
[AddComponentMenu("Xeric Library/DebugDrawLibrary/Screenspace/Camera Grid Visualizer")]
[DefaultExecutionOrder(31000)] //negative numers are early, positive numbers are late. Range is till 32000 to both negative and positive direction.
public class CameraGridVisualizer : VisualizerScreenspaceParent
{
[SerializeField] Color color = DrawBasics.defaultColor;
[SerializeField] [Range(0.0f, 0.1f)] float linesWidth_relToViewportHeight = 0.0f;
[SerializeField] bool drawTenthLines = true;
[SerializeField] bool drawHundredthLines = true;
[SerializeField] DrawEngineBasics.GridScreenspaceMode gridScreenspaceMode = DrawEngineBasics.GridScreenspaceMode.warpWidthAndHeightIndividuallyToFitScreenInBothAxes;
public override void InitializeValues_onceInComponentLifetime()
{
TrySetTextToEmptyString();
}
public override void InitializeValues_alsoOnPlaymodeEnter_andOnComponentCreatedAsCopy()
{
TryFetchCamOnThisGO_andDecideScreenspaceDefiningCamera();
}
public override void DrawVisualizedObject()
{
Camera usedCamera = Get_usedCamera("Camera Grid Visualizer Component");
if (usedCamera != null)
{
DrawEngineBasics.GridScreenspace(usedCamera, color, linesWidth_relToViewportHeight, drawTenthLines, drawHundredthLines, gridScreenspaceMode, 0.0f);
}
}
}
}