using CodeJay.Classes; using UnityEngine; public class ShowPanel : MonoBehaviour { public Camera m_Cam; public SpriteRenderer i_image; public GameObject[] gos_off; public GameObject go_btns, go_fullscreenclose; int zoomStep = 0; public void Set(HuntingData data) { gameObject.SetActive(true); DSUtil.InActivateGameObjects(gos_off); go_btns.SetActive(true); go_fullscreenclose.SetActive(false); i_image.sprite = data.HuntingImage; zoomStep = 0; m_Cam.orthographicSize = 4f; m_Cam.transform.position = new Vector3(0f, 0f, -10f); Set_ImageSize(); } void Set_ImageSize() { // 스프라이트의 원래 크기(픽셀 단위) float spriteWidth = i_image.sprite.bounds.size.x; float spriteHeight = i_image.sprite.bounds.size.y; // 카메라 float worldScreenHeight = m_Cam.orthographicSize * 2f; // 세로 크기(월드 단위) float worldScreenWidth = worldScreenHeight * m_Cam.aspect; // 가로 크기(월드 단위) // 배경 스케일 계산 i_image.transform.localScale = new Vector3( worldScreenWidth / spriteWidth, worldScreenHeight / spriteHeight, 1f ); } public void OnClick_Btn(int index) { switch (index) { case 0: // 나가기 gameObject.SetActive(false); DSUtil.ActivateGameObjects(gos_off); break; case 1: // 풀 스크린 go_btns.SetActive(false); go_fullscreenclose.SetActive(true); break; case 2: // 확대 (2단계까지만) ++zoomStep; if (zoomStep > 2) zoomStep = 2; m_Cam.orthographicSize = 4 - zoomStep; break; case 3: // 축소 --zoomStep; if (zoomStep < 0) zoomStep = 0; m_Cam.orthographicSize = 4 - zoomStep; m_Cam.transform.position = new Vector3(0f, 0f, -10f); break; case 4: // UI 다시 보이기 go_btns.SetActive(true); go_fullscreenclose.SetActive(false); break; } } }