45 lines
1.5 KiB
C#
45 lines
1.5 KiB
C#
using UnityEngine;
|
|
using Shapes;
|
|
|
|
namespace AibisDream.MiniGame.HuoShan
|
|
{
|
|
[ExecuteAlways]
|
|
public class ScreenTopLine : ImmediateModeShapeDrawer
|
|
{
|
|
[Header("Line Settings")]
|
|
[Tooltip("Reference to the screen transform")]
|
|
[SerializeField] private Transform screenTransform;
|
|
|
|
[SerializeField] private Color lineColor = Color.cyan;
|
|
[SerializeField] private float thickness = 0.05f;
|
|
[SerializeField] private ThicknessSpace thicknessSpace = ThicknessSpace.Meters;
|
|
[SerializeField] private float yOffset = 0f;
|
|
|
|
public override void DrawShapes(Camera cam)
|
|
{
|
|
if (screenTransform == null) return;
|
|
|
|
using (Draw.Command(cam))
|
|
{
|
|
Draw.ResetAllDrawStates();
|
|
Draw.BlendMode = ShapesBlendMode.Transparent;
|
|
Draw.LineGeometry = LineGeometry.Flat2D;
|
|
Draw.ThicknessSpace = thicknessSpace;
|
|
Draw.Thickness = thickness;
|
|
|
|
Vector3 pos = screenTransform.position;
|
|
Vector3 scale = screenTransform.lossyScale;
|
|
|
|
float halfWidth = scale.x / 2f;
|
|
float halfHeight = scale.y / 2f;
|
|
|
|
float topY = pos.y + halfHeight + yOffset;
|
|
Vector3 start = new Vector3(pos.x - halfWidth, topY, pos.z);
|
|
Vector3 end = new Vector3(pos.x + halfWidth, topY, pos.z);
|
|
|
|
Draw.Line(start, end, lineColor);
|
|
}
|
|
}
|
|
}
|
|
}
|