From a2f750c23417b348447f1d06908b2fd702e28260 Mon Sep 17 00:00:00 2001 From: ksh999000 <740612340@qq.com> Date: Mon, 6 Jul 2026 11:57:27 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=8A=80=E8=83=BD=E6=8C=89?= =?UTF-8?q?=E9=92=AE=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- unity/Assets/Editor/UIBuilder.cs | 44 ++++++++++++++++++++++--- unity/Assets/eco/SpiritLanternSystem.cs | 6 ++-- 2 files changed, 43 insertions(+), 7 deletions(-) diff --git a/unity/Assets/Editor/UIBuilder.cs b/unity/Assets/Editor/UIBuilder.cs index 15a5301..1c69990 100644 --- a/unity/Assets/Editor/UIBuilder.cs +++ b/unity/Assets/Editor/UIBuilder.cs @@ -1,6 +1,7 @@ using UnityEngine; using UnityEditor; using UnityEngine.UI; +using TMPro; using GameFramework; /// @@ -209,17 +210,17 @@ public static class UIBuilder skillLayout.childAlignment = TextAnchor.LowerRight; // 冲刺技能 - var sprintObj = CreateSkillIcon(skillArea.transform, "SkillSprint", sprintIconSprite, new Color(0.3f, 0.8f, 1f)); + var sprintObj = CreateSkillIcon(skillArea.transform, "SkillSprint", sprintIconSprite, new Color(0.3f, 0.8f, 1f), "空格"); so.FindProperty("skillSprintIcon").objectReferenceValue = sprintObj.transform.Find("Icon").GetComponent(); so.FindProperty("skillSprintCD").objectReferenceValue = sprintObj.transform.Find("CDOverlay").GetComponent(); // 摇铃技能 - var bellObj = CreateSkillIcon(skillArea.transform, "SkillBell", bellIconSprite, new Color(1f, 0.85f, 0.2f)); + var bellObj = CreateSkillIcon(skillArea.transform, "SkillBell", bellIconSprite, new Color(1f, 0.85f, 0.2f), "E"); so.FindProperty("skillBellIcon").objectReferenceValue = bellObj.transform.Find("Icon").GetComponent(); so.FindProperty("skillBellCD").objectReferenceValue = bellObj.transform.Find("CDOverlay").GetComponent(); // 灵灯技能 - var lanternObj = CreateSkillIcon(skillArea.transform, "SkillLantern", lanternIconSprite, new Color(1f, 0.6f, 0.2f)); + var lanternObj = CreateSkillIcon(skillArea.transform, "SkillLantern", lanternIconSprite, new Color(1f, 0.6f, 0.2f), "鼠标左键"); so.FindProperty("skillLanternIcon").objectReferenceValue = lanternObj.transform.Find("Icon").GetComponent(); so.FindProperty("skillLanternCD").objectReferenceValue = lanternObj.transform.Find("CDOverlay").GetComponent(); @@ -372,7 +373,7 @@ public static class UIBuilder return obj; } - private static GameObject CreateSkillIcon(Transform parent, string name, Sprite sprite, Color cdColor) + private static GameObject CreateSkillIcon(Transform parent, string name, Sprite sprite, Color cdColor, string keyText) { var container = new GameObject(name); container.transform.SetParent(parent, false); @@ -421,6 +422,41 @@ public static class UIBuilder cdImg.fillAmount = 0f; cdObj.SetActive(false); // 初始无 CD + // 按键提示标签(黑底白字,位于图标上方) + if (!string.IsNullOrEmpty(keyText)) + { + var hintObj = new GameObject("KeyHint"); + hintObj.transform.SetParent(container.transform, false); + var hintRect = hintObj.AddComponent(); + hintRect.anchorMin = new Vector2(0.5f, 1f); + hintRect.anchorMax = new Vector2(0.5f, 1f); + hintRect.pivot = new Vector2(0.5f, 0f); + hintRect.anchoredPosition = new Vector2(0, 6f); + hintRect.sizeDelta = new Vector2(60, 22); + + var hintBg = hintObj.AddComponent(); + hintBg.color = new Color(0, 0, 0, 0.85f); + + var textObj = new GameObject("Text"); + textObj.transform.SetParent(hintObj.transform, false); + var textRect = textObj.AddComponent(); + textRect.anchorMin = Vector2.zero; + textRect.anchorMax = Vector2.one; + textRect.sizeDelta = Vector2.zero; + + var tmp = textObj.AddComponent(); + tmp.text = keyText; + tmp.fontSize = 14; + tmp.fontStyle = FontStyles.Normal; + tmp.color = Color.white; + tmp.alignment = TextAlignmentOptions.Center; + + // 加载中文字体 + var font = AssetDatabase.LoadAssetAtPath( + "Assets/UI/Art/No.392-ShangShouNiShangTi-2 SDF.asset"); + if (font != null) tmp.font = font; + } + return container; } diff --git a/unity/Assets/eco/SpiritLanternSystem.cs b/unity/Assets/eco/SpiritLanternSystem.cs index 1dfa472..0ce5d75 100644 --- a/unity/Assets/eco/SpiritLanternSystem.cs +++ b/unity/Assets/eco/SpiritLanternSystem.cs @@ -22,7 +22,7 @@ namespace IndianOceanAssets.Engine2_5D [Header("冷却")] [Tooltip("放置灵灯的冷却时间(秒)")] - [SerializeField] private float cooldown = 5f; + [SerializeField] private float cooldown = 3.5f; [Header("灵灯预制体")] [SerializeField] private GameObject lanternPrefab; @@ -49,8 +49,8 @@ namespace IndianOceanAssets.Engine2_5D private void Update() { - // 按 U 且 CD 就绪 且 还有灵灯 → 放置 - if (Input.GetKeyDown(lanternKey) + // 按 U 或鼠标左键 且 CD 就绪 且 还有灵灯 → 放置 + if ((Input.GetKeyDown(lanternKey) || Input.GetMouseButtonDown(0)) && _remainingLanterns > 0 && Time.time > _lastPlaceTime + cooldown && lanternPrefab != null)