Files
Continentis/Assets/Scripts/MainGame/UI/HUDPage/HUDData.cs

33 lines
1.2 KiB
C#
Raw Normal View History

2025-10-23 00:49:44 -04:00
using System;
2025-10-03 00:02:43 -04:00
using Continentis.MainGame.Character;
2026-04-17 12:01:50 -04:00
using SLSUtilities.General;
2025-10-03 00:02:43 -04:00
using UnityEngine;
2025-10-23 00:49:44 -04:00
using Object = UnityEngine.Object;
2025-10-03 00:02:43 -04:00
namespace Continentis.MainGame.UI
{
[CreateAssetMenu(menuName = "Continentis/MainGame/HUD/HUDData", fileName = "HUDData")]
2026-03-20 11:56:50 -04:00
public class HUDData : ScriptableObject
2025-10-03 00:02:43 -04:00
{
2026-03-20 11:56:50 -04:00
[KeyWidth(0.25f)] public SerializableDictionary<string, HUDInfo> hudInfos;
2025-10-03 00:02:43 -04:00
}
2026-03-20 11:56:50 -04:00
2025-10-23 00:49:44 -04:00
[Serializable]
2025-10-03 00:02:43 -04:00
public class HUDInfo
{
public GameObject hudPrefab;
public string attachedPartName = "Center";
public Vector2 positionOffset = Vector2.zero;
public HUDElementBase GenerateHUD(CombatCharacterViewBase characterView, HUDContainer hudContainer)
{
2026-03-20 11:56:50 -04:00
var attachedPart = characterView.hudPivot.Find(attachedPartName) ?? characterView.hudPivot.GetChild(0);
var hudPageTransform = CombatUIManager.Instance.hudPage.rectTransform;
var element = Object.Instantiate(hudPrefab, hudPageTransform).GetComponent<HUDElementBase>();
2025-10-03 00:02:43 -04:00
element.SetPosition(attachedPart.position, positionOffset);
element.container = hudContainer;
element.hudTransform.SetParent(hudContainer.transform);
return element;
}
}
}