增加技能按钮说明
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using UnityEngine.UI;
|
||||
using TMPro;
|
||||
using GameFramework;
|
||||
|
||||
/// <summary>
|
||||
@@ -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<Image>();
|
||||
so.FindProperty("skillSprintCD").objectReferenceValue = sprintObj.transform.Find("CDOverlay").GetComponent<Image>();
|
||||
|
||||
// 摇铃技能
|
||||
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<Image>();
|
||||
so.FindProperty("skillBellCD").objectReferenceValue = bellObj.transform.Find("CDOverlay").GetComponent<Image>();
|
||||
|
||||
// 灵灯技能
|
||||
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<Image>();
|
||||
so.FindProperty("skillLanternCD").objectReferenceValue = lanternObj.transform.Find("CDOverlay").GetComponent<Image>();
|
||||
|
||||
@@ -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<RectTransform>();
|
||||
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<Image>();
|
||||
hintBg.color = new Color(0, 0, 0, 0.85f);
|
||||
|
||||
var textObj = new GameObject("Text");
|
||||
textObj.transform.SetParent(hintObj.transform, false);
|
||||
var textRect = textObj.AddComponent<RectTransform>();
|
||||
textRect.anchorMin = Vector2.zero;
|
||||
textRect.anchorMax = Vector2.one;
|
||||
textRect.sizeDelta = Vector2.zero;
|
||||
|
||||
var tmp = textObj.AddComponent<TextMeshProUGUI>();
|
||||
tmp.text = keyText;
|
||||
tmp.fontSize = 14;
|
||||
tmp.fontStyle = FontStyles.Normal;
|
||||
tmp.color = Color.white;
|
||||
tmp.alignment = TextAlignmentOptions.Center;
|
||||
|
||||
// 加载中文字体
|
||||
var font = AssetDatabase.LoadAssetAtPath<TMPro.TMP_FontAsset>(
|
||||
"Assets/UI/Art/No.392-ShangShouNiShangTi-2 SDF.asset");
|
||||
if (font != null) tmp.font = font;
|
||||
}
|
||||
|
||||
return container;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user