地图系统
This commit is contained in:
@@ -204,6 +204,14 @@ namespace BaseGames.Editor.UI
|
||||
AssignRef(hudCtrl, "_interactPromptWidget", interactWidget);
|
||||
AssignArrayRefs(hudCtrl, "_formIcons", formImages, report);
|
||||
|
||||
// ── HP 格子 / 回春图标 Prefab(自动创建并绑定,无需手工补)──────────
|
||||
GameObject hpCellPrefab = EnsureHUDIconPrefab("UI_HUD_HPCell",
|
||||
new Color32(0xD8, 0x3A, 0x3A, 0xFF), new Vector2(40, 40), report); // 面具红
|
||||
GameObject springPrefab = EnsureHUDIconPrefab("UI_HUD_SpringIcon",
|
||||
new Color32(0x4A, 0xC8, 0xF0, 0xFF), new Vector2(32, 32), report); // 灵泉青
|
||||
AssignRef(hudCtrl, "_hpCellPrefab", hpCellPrefab);
|
||||
AssignRef(hudCtrl, "_springIconPrefab", springPrefab);
|
||||
|
||||
// ── 事件频道 ──────────────────────────────────────────────────────
|
||||
AssignAsset(hudCtrl, "_onHPChanged", report, true, "EVT_HPChanged", "EVT_PlayerHPChanged");
|
||||
AssignAsset(hudCtrl, "_onMaxHPChanged", report, false, "EVT_MaxHPChanged", "EVT_PlayerMaxHPChanged");
|
||||
@@ -235,8 +243,7 @@ namespace BaseGames.Editor.UI
|
||||
AssignAsset(toolHUD, "_onToolUsed", report, false, "EVT_ToolUsed");
|
||||
|
||||
// ── 手工步骤说明 ──────────────────────────────────────────────────
|
||||
report.Add("HUDController._hpCellPrefab:请将 HP 格子 Prefab 赋给该字段。");
|
||||
report.Add("HUDController._springIconPrefab:请将回春图标 Prefab 赋给该字段。");
|
||||
// _hpCellPrefab / _springIconPrefab 已自动创建并绑定(占位红/青方块,美术可替换)。
|
||||
report.Add("BossHPBar._phaseMarkerPrefab:请将阶段标记点 Prefab 赋给该字段。");
|
||||
report.Add("StatusEffectHUD._slotConfigs:请在 Inspector 中配置各状态效果的图标映射。");
|
||||
|
||||
@@ -248,6 +255,39 @@ namespace BaseGames.Editor.UI
|
||||
// Private helpers
|
||||
// ─────────────────────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>
|
||||
/// 创建(或复用)一个 HUD 图标 Prefab(含 RectTransform + Image + LayoutElement),
|
||||
/// 用作 HUDController._hpCellPrefab / _springIconPrefab。占位纯色方块,美术后续可替换 sprite。
|
||||
/// 路径:Assets/_Game/Prefabs/UI/{prefabName}.prefab(符合 AssetFolderSpec.md §4 UI 前缀)。
|
||||
/// </summary>
|
||||
private static GameObject EnsureHUDIconPrefab(string prefabName, Color color, Vector2 size, List<string> report)
|
||||
{
|
||||
const string uiDir = "Assets/_Game/Prefabs/UI";
|
||||
string path = $"{uiDir}/{prefabName}.prefab";
|
||||
|
||||
var existing = AssetDatabase.LoadAssetAtPath<GameObject>(path);
|
||||
if (existing != null) return existing;
|
||||
|
||||
if (!AssetDatabase.IsValidFolder("Assets/_Game/Prefabs"))
|
||||
AssetDatabase.CreateFolder("Assets/_Game", "Prefabs");
|
||||
if (!AssetDatabase.IsValidFolder(uiDir))
|
||||
AssetDatabase.CreateFolder("Assets/_Game/Prefabs", "UI");
|
||||
|
||||
var go = new GameObject(prefabName, typeof(RectTransform));
|
||||
var rt = go.GetComponent<RectTransform>();
|
||||
rt.sizeDelta = size;
|
||||
var img = go.AddComponent<UnityEngine.UI.Image>();
|
||||
img.color = color;
|
||||
var le = go.AddComponent<UnityEngine.UI.LayoutElement>();
|
||||
le.preferredWidth = size.x;
|
||||
le.preferredHeight = size.y;
|
||||
|
||||
var prefab = PrefabUtility.SaveAsPrefabAsset(go, path);
|
||||
Object.DestroyImmediate(go);
|
||||
report.Add($"已自动创建 HUD 图标 Prefab:{path}(占位纯色,美术可替换)。");
|
||||
return prefab;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 在活动场景中查找或创建 HUD Canvas。
|
||||
/// 查找顺序:
|
||||
|
||||
Reference in New Issue
Block a user