feat(huoshan): 校准表达屏布局与状态文字
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -45,6 +45,8 @@ namespace AibisDream.MiniGame.Language
|
||||
[Header("Frame Animation")]
|
||||
[SerializeField] private SpriteRenderer screenRenderer;
|
||||
[SerializeField] private Sprite[] frames = new Sprite[53];
|
||||
[SerializeField] private Vector3 screenLocalPosition = new Vector3(0.68f, -8.95f, 0f);
|
||||
[SerializeField] private Vector3 screenLocalScale = new Vector3(1.1f, 1.1f, 1f);
|
||||
|
||||
[Header("Existing TMP / Interaction")]
|
||||
[SerializeField] private TMP_Text integrationProgressText;
|
||||
@@ -52,6 +54,18 @@ namespace AibisDream.MiniGame.Language
|
||||
[SerializeField] private Button outputButton;
|
||||
[SerializeField] private TMP_FontAsset screenFont;
|
||||
|
||||
[Header("Status TMP (screen-space world units)")]
|
||||
[SerializeField] private Vector2 integrationStatusPosition = new Vector2(-8.75f, 4.15f);
|
||||
[SerializeField] private Vector2 interferenceStatusPosition = new Vector2(-8.75f, 3.08f);
|
||||
[SerializeField] private Vector2 statusPanelSize = new Vector2(4.55f, 0.6f);
|
||||
[SerializeField] private Vector4 statusTextMargins = new Vector4(0.16f, 0.05f, 0.08f, 0.05f);
|
||||
[SerializeField] private float statusFontSize = 0.26f;
|
||||
[SerializeField] private Color screenTextColor = new Color(0.78f, 0.91f, 1f, 1f);
|
||||
|
||||
[Header("Output Button Hit Area")]
|
||||
[SerializeField] private Vector2 outputButtonPosition = new Vector2(4.86f, -0.065f);
|
||||
[SerializeField] private Vector2 outputButtonSize = new Vector2(2.72f, 1.13f);
|
||||
|
||||
[Header("Objective TMP (384x216 reference)")]
|
||||
[SerializeField] private Vector2 objectivePosition = new Vector2(-8.18f, -4.08f);
|
||||
[SerializeField] private Vector2 objectiveSize = new Vector2(7.4f, 0.95f);
|
||||
@@ -96,6 +110,12 @@ namespace AibisDream.MiniGame.Language
|
||||
{
|
||||
outputText = outputButton.GetComponentInChildren<TMP_Text>(true);
|
||||
}
|
||||
|
||||
if (screenRenderer != null)
|
||||
{
|
||||
screenRenderer.transform.localPosition = screenLocalPosition;
|
||||
screenRenderer.transform.localScale = screenLocalScale;
|
||||
}
|
||||
}
|
||||
|
||||
private void ConfigureExistingUiAsTextOnly()
|
||||
@@ -103,10 +123,9 @@ namespace AibisDream.MiniGame.Language
|
||||
MakeParentImageTransparent(integrationProgressText);
|
||||
MakeParentImageTransparent(interferenceCountText);
|
||||
|
||||
if (integrationProgressText != null)
|
||||
integrationProgressText.raycastTarget = false;
|
||||
if (interferenceCountText != null)
|
||||
interferenceCountText.raycastTarget = false;
|
||||
ConfigureStatusText(integrationProgressText, integrationStatusPosition);
|
||||
ConfigureStatusText(interferenceCountText, interferenceStatusPosition);
|
||||
ConfigureOutputText();
|
||||
|
||||
if (outputButton != null && outputButton.targetGraphic != null)
|
||||
{
|
||||
@@ -117,6 +136,75 @@ namespace AibisDream.MiniGame.Language
|
||||
}
|
||||
}
|
||||
|
||||
private void ConfigureStatusText(TMP_Text text, Vector2 panelPosition)
|
||||
{
|
||||
if (text == null)
|
||||
return;
|
||||
|
||||
if (screenFont != null)
|
||||
text.font = screenFont;
|
||||
|
||||
text.fontSize = statusFontSize;
|
||||
text.fontStyle = FontStyles.Normal;
|
||||
text.color = screenTextColor;
|
||||
text.alignment = TextAlignmentOptions.MidlineLeft;
|
||||
text.enableWordWrapping = false;
|
||||
text.overflowMode = TextOverflowModes.Truncate;
|
||||
text.margin = statusTextMargins;
|
||||
text.raycastTarget = false;
|
||||
|
||||
if (text.transform.parent is RectTransform panelRect)
|
||||
{
|
||||
panelRect.anchorMin = new Vector2(0.5f, 0.5f);
|
||||
panelRect.anchorMax = new Vector2(0.5f, 0.5f);
|
||||
panelRect.pivot = new Vector2(0f, 0.5f);
|
||||
panelRect.anchoredPosition = panelPosition;
|
||||
panelRect.sizeDelta = statusPanelSize;
|
||||
}
|
||||
|
||||
RectTransform textRect = text.rectTransform;
|
||||
textRect.anchorMin = Vector2.zero;
|
||||
textRect.anchorMax = Vector2.one;
|
||||
textRect.pivot = new Vector2(0.5f, 0.5f);
|
||||
textRect.anchoredPosition = Vector2.zero;
|
||||
textRect.sizeDelta = Vector2.zero;
|
||||
}
|
||||
|
||||
private void ConfigureOutputText()
|
||||
{
|
||||
if (outputButton == null)
|
||||
return;
|
||||
|
||||
RectTransform buttonRect = outputButton.transform as RectTransform;
|
||||
if (buttonRect != null)
|
||||
{
|
||||
buttonRect.anchorMin = new Vector2(0.5f, 0.5f);
|
||||
buttonRect.anchorMax = new Vector2(0.5f, 0.5f);
|
||||
buttonRect.pivot = new Vector2(0f, 0.5f);
|
||||
buttonRect.anchoredPosition = outputButtonPosition;
|
||||
buttonRect.sizeDelta = outputButtonSize;
|
||||
}
|
||||
|
||||
if (outputText == null)
|
||||
return;
|
||||
|
||||
if (screenFont != null)
|
||||
outputText.font = screenFont;
|
||||
|
||||
outputText.fontStyle = FontStyles.Normal;
|
||||
outputText.color = screenTextColor;
|
||||
outputText.alignment = TextAlignmentOptions.Center;
|
||||
outputText.enableWordWrapping = false;
|
||||
outputText.overflowMode = TextOverflowModes.Truncate;
|
||||
|
||||
RectTransform textRect = outputText.rectTransform;
|
||||
textRect.anchorMin = Vector2.zero;
|
||||
textRect.anchorMax = Vector2.one;
|
||||
textRect.pivot = new Vector2(0.5f, 0.5f);
|
||||
textRect.anchoredPosition = Vector2.zero;
|
||||
textRect.sizeDelta = Vector2.zero;
|
||||
}
|
||||
|
||||
private static void MakeParentImageTransparent(TMP_Text text)
|
||||
{
|
||||
if (text == null || text.transform.parent == null)
|
||||
@@ -177,9 +265,9 @@ namespace AibisDream.MiniGame.Language
|
||||
text.fontSharedMaterial = objectiveMaterial;
|
||||
}
|
||||
text.fontSize = objectiveFontSize;
|
||||
text.fontStyle = FontStyles.Bold;
|
||||
text.fontStyle = FontStyles.Normal;
|
||||
text.color = objectiveColor;
|
||||
text.alignment = TextAlignmentOptions.Left;
|
||||
text.alignment = TextAlignmentOptions.MidlineLeft;
|
||||
text.enableWordWrapping = true;
|
||||
text.overflowMode = TextOverflowModes.Truncate;
|
||||
text.raycastTarget = false;
|
||||
|
||||
Reference in New Issue
Block a user