fix(fix-system): 扩大热力图拖拽命中范围
This commit is contained in:
@@ -20,6 +20,9 @@ public class HeatMapController : MonoBehaviour
|
||||
|
||||
public RectTransform imageToMove; // 需要移动的Image
|
||||
public Transform imageToRotate; // 需要旋转的Image
|
||||
[Header("拖拽")]
|
||||
[Tooltip("在不改变视觉和布局的前提下,向左右/上下扩展拖拽命中范围。")]
|
||||
[SerializeField] private Vector2 dragHitAreaExpansion = new Vector2(5.2f, 0.3f);
|
||||
[SerializeField, Min(0f)] private float fanStopDuration = 0.15f;
|
||||
[Tooltip("相对 Sprite 矩形中心的额外旋转轴偏移(本地空间,单位与 Transform 一致)。用于校准扇毂不在图心时的偏心。")]
|
||||
[SerializeField] private Vector2 fanPivotLocalOffset;
|
||||
@@ -227,10 +230,31 @@ public class HeatMapController : MonoBehaviour
|
||||
void Start()
|
||||
{
|
||||
bodyModuleSystem = FindObjectOfType<BodyModuleSystem>();
|
||||
ApplyDragHitArea();
|
||||
EnsureFanPivot();
|
||||
SetDataToMaterial();
|
||||
}
|
||||
|
||||
private void ApplyDragHitArea()
|
||||
{
|
||||
if (heatmapGameobject == null)
|
||||
return;
|
||||
|
||||
var dragGraphic = heatmapGameobject.GetComponent<Graphic>();
|
||||
if (dragGraphic == null)
|
||||
{
|
||||
Debug.LogWarning("[HeatMapController] 拖拽对象缺少 Graphic,无法扩展拖拽命中范围。", heatmapGameobject);
|
||||
return;
|
||||
}
|
||||
|
||||
float horizontal = Mathf.Max(0f, dragHitAreaExpansion.x);
|
||||
float vertical = Mathf.Max(0f, dragHitAreaExpansion.y);
|
||||
|
||||
// Graphic 使用负 raycastPadding 扩展命中区;不会改变 RectTransform,
|
||||
// 因而不会移动右上角按钮或拉伸热力图内容。
|
||||
dragGraphic.raycastPadding = new Vector4(-horizontal, -vertical, -horizontal, -vertical);
|
||||
}
|
||||
|
||||
void OnDestroy()
|
||||
{
|
||||
_temptureTween?.Kill();
|
||||
|
||||
Reference in New Issue
Block a user