ThreeKingdomsSlingshot/Assets/Scripts/OutGame/Arena/ArenaHubView.cs

54 lines
2.3 KiB
C#
Raw Normal View History

투기장 · 연의 전기 아트 화면 게임 반영 (PD 2026-11-18 「투기장 UI 완료」 · 「연의 전기 통과」 · 「모두 반영하고 푸시까지」) - 투기장(연무장 page 3) = ArenaLeague + 표 폴더 Resources/UI/League(긴 배경 1080×2340 · 자리 표 납품 그대로 · 설정 표 · 글자 키 · 부품 9 분할 import.json) · 아틀라스 UI_League · 층 Content/Art(Static) · Scene(Frame) · Info(Event + 레이캐스터) - 연의 전기(연무장 page 5) = ArenaScenario(ScenarioFit 화면 맞춤 · ScenarioOpenFx 펼침 6단계) + 표 폴더 Resources/UI/Scenario(탭 배경 5 · 납품 표 3 그대로 · 설정 표 · 글자 키 · 두루마리 8 + 상세 두루마리 9 분할 + 고름 빛) · 아틀라스 UI_Scenario · 상세 = 위 덮개 루트 · 뒤로 = 상세만 닫기 - 공용: ArenaScreen(아트 화면 켜기 · 제목 띠 공용 ViewHeader) · UnitArtImporter(UI/League · UI/Scenario 분기 · 하위 폴더 import.json · max 칸) · UICaptureDriver(LeagueShots · ScenarioShots) · ui_atlas.csv 2줄 · CLAUDE.md 2줄 - 테스트 ArenaLeagueTests · ArenaScenarioTests - 컴파일에 필요해 함께 넣은 다른 세션 파일 = OutGame/UI/UiText.cs · OutGame/Arena/ArenaHubView.cs(연무장 허브 세션 작성) — 허브 본체 · 보물 · 로비 변경은 넣지 않음(공용 파일은 이 작업 줄만) - 검증: 이 커밋 묶음만 둔 사본에서 컴파일 오류 0 · 두 테스트 2/2 통과 · 본체 에디터 콘솔 error 0 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 05:48:47 +00:00
using UnityEngine;
using UnityEngine.UI;
namespace TKS.OutGame
{
/// <summary>
/// 연무장 허브 화면 맞춤 — 화면(이 RectTransform) 크기가 바뀔 때마다 배율을 다시 정한다:
/// 기준 칸(표 box · 16:9 폰 1080×1920)이 화면에 다 담기는 가장 큰 배율 · 단 그림이 화면을 다 덮도록(그림 밖이 비지 않게) · 기준 칸 가운데 = 화면 가운데 →
/// 남는 쪽(세로 긴 폰 = 위아래 · 태블릿 = 좌우)은 그림이 더 보이고 좌우는 끌어서 스크롤(ScrollRect · 가로만).
/// </summary>
public class ArenaHubView : MonoBehaviour
{
public RectTransform content;
public ScrollRect scroll;
/// <summary>그림 좌표계 크기(캔버스 px).</summary>
public Vector2 canvasSize;
/// <summary>기준 칸(x · y = 왼쪽 위 · 폭 · 높이 · 캔버스 px).</summary>
public Rect box;
Vector2 lastSize;
public float Zoom { get; private set; }
void OnEnable()
{
Fit(true);
}
void OnRectTransformDimensionsChange()
{
Fit(false);
}
public void Fit(bool force)
{
if (content == null || canvasSize.x < 1f || canvasSize.y < 1f || box.width < 1f || box.height < 1f) return;
var r = ((RectTransform)transform).rect;
if (r.width < 1f || r.height < 1f) return;
if (!force && (r.size - lastSize).sqrMagnitude < 0.01f) return;
lastSize = r.size;
float z = Mathf.Max(Mathf.Min(r.width / box.width, r.height / box.height), Mathf.Max(r.width / canvasSize.x, r.height / canvasSize.y));
Zoom = z;
content.localScale = new Vector3(z, z, 1f);
// 기준 칸 가운데를 화면 가운데로 — 그림이 화면 밖으로 비지 않게 자름
float ox = (canvasSize.x * 0.5f - box.center.x) * z;
float oy = (box.center.y - canvasSize.y * 0.5f) * z;
float mx = Mathf.Max(0f, (canvasSize.x * z - r.width) * 0.5f);
float my = Mathf.Max(0f, (canvasSize.y * z - r.height) * 0.5f);
if (scroll != null) scroll.StopMovement();
content.anchoredPosition = new Vector2(Mathf.Clamp(ox, -mx, mx), Mathf.Clamp(oy, -my, my));
}
}
}