36 lines
1.3 KiB
C#
36 lines
1.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Continentis.MainGame.Character;
|
|
using NaughtyAttributes;
|
|
using SLSFramework.General;
|
|
using UnityEngine;
|
|
using Object = UnityEngine.Object;
|
|
|
|
namespace Continentis.MainGame.UI
|
|
{
|
|
[CreateAssetMenu(menuName = "Continentis/MainGame/HUD/HUDData", fileName = "HUDData")]
|
|
public partial class HUDData : ScriptableObject
|
|
{
|
|
[KeyWidth(0.25f)]
|
|
public SerializableDictionary<string, HUDInfo> hudInfos;
|
|
}
|
|
|
|
[Serializable]
|
|
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;
|
|
}
|
|
}
|
|
} |