SHA256
Add Progress Bar to DebugMonitorUI
This commit is contained in:
1 parent
156cec4f7f
commit
c8a790ce9d
5 files changed
+141
-21
No files matched your search
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+141
-21
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
@@ -7,7 +8,58 @@ namespace ADOFAIRenderer.Component
|
||||
{
|
||||
public class DebugMonitorUI : MonoBehaviour
|
||||
{
|
||||
private Text _text = null!;
|
||||
// --- Progress Bar UI Configuration Constants ---
|
||||
private const float BarWidth = 800f;
|
||||
private const float BarHeight = 28f;
|
||||
private const float BarPosX = 0f;
|
||||
private const float BarPosY = -420f; // Y position relative to screen center (Reference: 1920x1080)
|
||||
private const int BarTextFontSize = 16; // 눈에 띄게 증가된 텍스트 크기
|
||||
private static readonly Color BarBackgroundColor = new Color(0.08f, 0.08f, 0.1f, 0.7f);
|
||||
private static readonly Color BarFillColor = new Color(0.0f, 0.8f, 1.0f, 1.0f); // Sleek cyan/blue
|
||||
private static readonly Color BarTextColor = new Color(1.0f, 1.0f, 1.0f, 0.7f);
|
||||
|
||||
// --- Progress Bar Outline Configuration Constants ---
|
||||
private static readonly Color BarOutlineColor = Color.white; // 대비되는 흰색 윤곽선
|
||||
private static readonly Vector2 BarOutlineDistance = new Vector2(3.0f, -3.0f); // 3px의 굵고 직관적인 윤곽선 두께
|
||||
|
||||
private TextMeshProUGUI _text = null!;
|
||||
private GameObject _progressBarObj = null!;
|
||||
private GameObject _progressBarFillObj = null!;
|
||||
private RectTransform _fillRect = null!;
|
||||
private TextMeshProUGUI _progressText = null!;
|
||||
|
||||
private static TMP_FontAsset GetNanumSquareNeoBdFontAsset()
|
||||
{
|
||||
TMP_FontAsset? font = null;
|
||||
if (RenderMod.FontBundle != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
font = RenderMod.FontBundle.LoadAsset<TMP_FontAsset>("NanumSquareNeoOTF-Bd SDF");
|
||||
}
|
||||
catch
|
||||
{
|
||||
// 로딩 실패
|
||||
}
|
||||
}
|
||||
|
||||
// 폴백 처리: 에셋 번들에서 실패 시 게임 자체 NanumSquareNeo 또는 내장 TMP SDF 폰트 사용
|
||||
if (font == null)
|
||||
{
|
||||
font = RDString.fontData.fontTMP;
|
||||
}
|
||||
if (font == null)
|
||||
{
|
||||
// ReSharper disable once Unity.UnknownResource
|
||||
font = Resources.Load<TMP_FontAsset>("Fonts & Materials/LiberationSans SDF");
|
||||
}
|
||||
|
||||
if (font != null) return font;
|
||||
var fonts = Resources.FindObjectsOfTypeAll<TMP_FontAsset>();
|
||||
if (fonts.Length > 0) font = fonts[0];
|
||||
|
||||
return font!;
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
@@ -48,33 +100,83 @@ namespace ADOFAIRenderer.Component
|
||||
textObj.transform.SetParent(panelObj.transform, false);
|
||||
textObj.layer = 5;
|
||||
|
||||
_text = textObj.AddComponent<Text>();
|
||||
_text.supportRichText = true;
|
||||
_text.fontSize = 13;
|
||||
_text.lineSpacing = 1.3f;
|
||||
_text.alignment = TextAnchor.UpperLeft;
|
||||
_text = textObj.AddComponent<TextMeshProUGUI>();
|
||||
_text.richText = true;
|
||||
_text.fontSize = 16; // 13에서 16으로 증가
|
||||
_text.alignment = TextAlignmentOptions.TopLeft;
|
||||
|
||||
// uGUI 특유의 텍스트 잘림 현상 원천 예방
|
||||
_text.horizontalOverflow = HorizontalWrapMode.Wrap;
|
||||
_text.verticalOverflow = VerticalWrapMode.Overflow;
|
||||
// TMPro 텍스트 잘림 현상 예방
|
||||
_text.textWrappingMode = TextWrappingModes.Normal;
|
||||
_text.overflowMode = TextOverflowModes.Overflow;
|
||||
|
||||
var font = Resources.GetBuiltinResource<Font>("LegacyRuntime.ttf");
|
||||
if (font == null)
|
||||
{
|
||||
font = Resources.GetBuiltinResource<Font>("Arial.ttf");
|
||||
}
|
||||
if (font == null)
|
||||
{
|
||||
var fonts = Resources.FindObjectsOfTypeAll<Font>();
|
||||
if (fonts.Length > 0) font = fonts[0];
|
||||
}
|
||||
// NanumSquareNeo-Bd SDF 폰트 로드 및 적용
|
||||
var font = GetNanumSquareNeoBdFontAsset();
|
||||
_text.font = font;
|
||||
|
||||
RectTransform textRect = textObj.GetComponent<RectTransform>();
|
||||
var textRect = textObj.GetComponent<RectTransform>();
|
||||
textRect.anchorMin = Vector2.zero;
|
||||
textRect.anchorMax = Vector2.one;
|
||||
textRect.offsetMin = new Vector2(20, 20); // 좀 더 넉넉하고 아름다운 패딩 여백
|
||||
textRect.offsetMin = new Vector2(20, 20); // 좀 더 넉넉하고 패딩 여백
|
||||
textRect.offsetMax = new Vector2(-20, -20);
|
||||
|
||||
// --- Progress Bar UI Setup ---
|
||||
// 1. Progress Bar Container
|
||||
_progressBarObj = new GameObject("ProgressBar");
|
||||
_progressBarObj.transform.SetParent(transform, false);
|
||||
_progressBarObj.layer = 5;
|
||||
|
||||
var bgImage = _progressBarObj.AddComponent<Image>();
|
||||
bgImage.color = BarBackgroundColor;
|
||||
|
||||
// 프로그레스 바 흰색 윤곽선 컴포넌트 추가
|
||||
var bgOutline = _progressBarObj.AddComponent<Outline>();
|
||||
bgOutline.effectColor = BarOutlineColor;
|
||||
bgOutline.effectDistance = BarOutlineDistance;
|
||||
|
||||
var barRect = _progressBarObj.GetComponent<RectTransform>();
|
||||
barRect.anchorMin = new Vector2(0.5f, 0.5f);
|
||||
barRect.anchorMax = new Vector2(0.5f, 0.5f);
|
||||
barRect.pivot = new Vector2(0.5f, 0.5f);
|
||||
barRect.anchoredPosition = new Vector2(BarPosX, BarPosY);
|
||||
barRect.sizeDelta = new Vector2(BarWidth, BarHeight);
|
||||
|
||||
// 2. Progress Bar Fill
|
||||
_progressBarFillObj = new GameObject("ProgressBarFill");
|
||||
_progressBarFillObj.transform.SetParent(_progressBarObj.transform, false);
|
||||
_progressBarFillObj.layer = 5;
|
||||
|
||||
var fillImage = _progressBarFillObj.AddComponent<Image>();
|
||||
fillImage.color = BarFillColor;
|
||||
|
||||
_fillRect = _progressBarFillObj.GetComponent<RectTransform>();
|
||||
_fillRect.anchorMin = new Vector2(0, 0);
|
||||
_fillRect.anchorMax = new Vector2(0, 1);
|
||||
_fillRect.pivot = new Vector2(0, 0.5f);
|
||||
_fillRect.anchoredPosition = Vector2.zero;
|
||||
_fillRect.sizeDelta = new Vector2(0, 0); // width will be updated dynamically in Update()
|
||||
|
||||
// 3. Progress Bar Text
|
||||
var progressTextObj = new GameObject("ProgressBarText");
|
||||
progressTextObj.transform.SetParent(_progressBarObj.transform, false);
|
||||
progressTextObj.layer = 5;
|
||||
|
||||
_progressText = progressTextObj.AddComponent<TextMeshProUGUI>();
|
||||
_progressText.richText = true;
|
||||
_progressText.fontSize = BarTextFontSize; // 14에서 18로 증가
|
||||
_progressText.alignment = TextAlignmentOptions.Center;
|
||||
_progressText.font = font;
|
||||
_progressText.color = BarTextColor;
|
||||
|
||||
// 프로그레스 바 내부 텍스트 아웃라인 추가 (진행율 가독성 확보)
|
||||
var textOutline = progressTextObj.AddComponent<Outline>();
|
||||
textOutline.effectColor = new Color(0f, 0f, 0f, 0.9f);
|
||||
textOutline.effectDistance = new Vector2(1.5f, -1.5f);
|
||||
|
||||
var textRectBar = progressTextObj.GetComponent<RectTransform>();
|
||||
textRectBar.anchorMin = Vector2.zero;
|
||||
textRectBar.anchorMax = Vector2.one;
|
||||
textRectBar.offsetMin = Vector2.zero;
|
||||
textRectBar.offsetMax = Vector2.zero;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
@@ -105,6 +207,24 @@ namespace ADOFAIRenderer.Component
|
||||
sb.AppendLine($"• Mono Heap Memory: {memoryMb:F2} MB");
|
||||
|
||||
_text.text = sb.ToString();
|
||||
|
||||
// Update Progress Bar
|
||||
var progress = 0f;
|
||||
int currentFloor = 0;
|
||||
int totalFloors = 0;
|
||||
|
||||
if (scrController.instance && ADOBase.lm && ADOBase.lm.listFloors != null)
|
||||
{
|
||||
currentFloor = scrController.instance.currFloor ? scrController.instance.currFloor.seqID : 0;
|
||||
totalFloors = ADOBase.lm.listFloors.Count;
|
||||
if (totalFloors > 0)
|
||||
{
|
||||
progress = Mathf.Clamp01((float)currentFloor / totalFloors);
|
||||
}
|
||||
}
|
||||
|
||||
if (_fillRect) _fillRect.sizeDelta = new Vector2(BarWidth * progress, 0);
|
||||
if (_progressText) _progressText.text = $"{progress * 100f:F1}% ({currentFloor}/{totalFloors})";
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user