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

36 lines
1.3 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 System.Collections.Generic;
using Continentis.MainGame.Character;
2025-10-23 00:49:44 -04:00
using NaughtyAttributes;
using SLSFramework.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")]
2025-10-23 00:49:44 -04:00
public partial class HUDData : ScriptableObject
2025-10-03 00:02:43 -04:00
{
2025-10-23 00:49:44 -04:00
[KeyWidth(0.25f)]
public SerializableDictionary<string, HUDInfo> hudInfos;
2025-10-03 00:02:43 -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)
{
Transform attachedPart = characterView.hudPivot.Find(attachedPartName) ?? characterView.hudPivot.GetChild(0);
RectTransform hudPageTransform = CombatUIManager.Instance.hudPage.rectTransform;
HUDElementBase element = Object.Instantiate(hudPrefab, hudPageTransform).GetComponent<HUDElementBase>();
element.SetPosition(attachedPart.position, positionOffset);
element.container = hudContainer;
element.hudTransform.SetParent(hudContainer.transform);
return element;
}
}
}