Story排版

This commit is contained in:
SoulliesOfficial
2026-07-20 16:56:04 -04:00
parent 04ec368a59
commit c30bb258b1
107 changed files with 7794 additions and 969 deletions

View File

@@ -38,6 +38,8 @@ namespace Ichni.Story.UI
Vector2 startPosition = GetLocalPoint(startBlock.outPort, selfRect, uiCamera);
Vector2 endPosition = GetLocalPoint(endBlock.inPort, selfRect, uiCamera);
Vector2 startBlockCenter = GetLocalRectCenter(startBlock.blockRect, selfRect, uiCamera);
Vector2 endBlockCenter = GetLocalRectCenter(endBlock.blockRect, selfRect, uiCamera);
if (Vector2.Distance(startPosition, endPosition) < DegenerateDistanceThreshold)
{
@@ -47,7 +49,10 @@ namespace Ichni.Story.UI
}
// 两个控制点构成 S 形:先水平离开起点,再水平进入终点。
float midX = (startPosition.x + endPosition.x) / 2f;
// 转折列取两个 Block 的逻辑中心中点,而不是两个端口的中点。
// 这样当目标 Block 的宽度不同(例如 Important 与 Secondary但位于同一列时
// 连接线仍会在同一条竖线转折;尺寸差异只影响端口到转折列的水平线长度。
float midX = (startBlockCenter.x + endBlockCenter.x) * 0.5f;
Vector2 mid1 = new Vector2(midX, startPosition.y);
Vector2 mid2 = new Vector2(midX, endPosition.y);
@@ -66,6 +71,19 @@ namespace Ichni.Story.UI
return localPoint;
}
/// <summary>
/// 将任意 RectTransform 的视觉中心转换为连接线容器的局部坐标。
/// 使用 rect.center 而非 transform.position因此不依赖 Block Prefab 自身的 Pivot 配置;
/// StoryBlockView 运行时统一为中心 Pivot 后,仍可安全用于未来的任意尺寸 Block。
/// </summary>
private static Vector2 GetLocalRectCenter(RectTransform rect, RectTransform space, Camera uiCamera)
{
Vector3 worldCenter = rect.TransformPoint(rect.rect.center);
Vector2 screenPoint = RectTransformUtility.WorldToScreenPoint(uiCamera, worldCenter);
RectTransformUtility.ScreenPointToLocalPointInRectangle(space, screenPoint, uiCamera, out Vector2 localPoint);
return localPoint;
}
/// <summary>
/// 解析用于坐标转换的相机Overlay 画布返回 null其余ScreenSpaceCamera / WorldSpace返回画布相机。
/// </summary>