2025-06-07 17:43:34 +08:00

23 lines
621 B
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using UnityEngine;
using UnityEngine.UI;
/// <summary>
/// 用于不做渲染的UI对象仅保留射线检测
/// </summary>
[RequireComponent(typeof(CanvasRenderer))]
public class NonDrawingGraphic : Graphic
{
protected override void Awake()
{
color = new Color(0, 0, 0, 0);
}
protected override void OnPopulateMesh(VertexHelper vh)
{
vh.Clear();
}
// 如果不需要渲染,可以直接覆盖 SetMaterialDirty 和 SetVerticesDirty 方法来防止不必要的重绘调用
public override void SetMaterialDirty() { }
public override void SetVerticesDirty() { }
}