diff --git a/Assets/JAY/Main-Jay.unity b/Assets/JAY/Main-Jay.unity index b6fabf7..71392e1 100644 --- a/Assets/JAY/Main-Jay.unity +++ b/Assets/JAY/Main-Jay.unity @@ -122,6 +122,81 @@ NavMeshSettings: debug: m_Flags: 0 m_NavMeshData: {fileID: 0} +--- !u!1 &241685775 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 241685776} + - component: {fileID: 241685778} + - component: {fileID: 241685777} + m_Layer: 5 + m_Name: Win Panel + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &241685776 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 241685775} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 1867732347} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &241685777 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 241685775} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 0.392} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 10907, guid: 0000000000000000f000000000000000, type: 0} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &241685778 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 241685775} + m_CullTransparentMesh: 1 --- !u!1 &271965288 GameObject: m_ObjectHideFlags: 0 @@ -132,6 +207,7 @@ GameObject: m_Component: - component: {fileID: 271965289} - component: {fileID: 271965290} + - component: {fileID: 271965291} m_Layer: 0 m_Name: GameManager m_TagString: Untagged @@ -139,14 +215,13 @@ GameObject: m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!4 &271965289 -Transform: +--- !u!224 &271965289 +RectTransform: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 271965288} - serializedVersion: 2 m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} @@ -154,6 +229,11 @@ Transform: m_Children: [] m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 100, y: 100} + m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &271965290 MonoBehaviour: m_ObjectHideFlags: 0 @@ -176,6 +256,29 @@ MonoBehaviour: giboPanel: {fileID: 3090474328172188941, guid: c63914e01332f8d479ada92325335e41, type: 3} loadingPanel: {fileID: 1942997847427067673, guid: 634a60576b4855940a97d1e7447b9fcc, type: 3} profileSprites: [] +--- !u!223 &271965291 +Canvas: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 271965288} + m_Enabled: 1 + serializedVersion: 3 + m_RenderMode: 2 + m_Camera: {fileID: 0} + m_PlaneDistance: 100 + m_PixelPerfect: 0 + m_ReceivesEvents: 1 + m_OverrideSorting: 0 + m_OverridePixelPerfect: 0 + m_SortingBucketNormalizedSize: 0 + m_VertexColorAlwaysGammaSpace: 0 + m_AdditionalShaderChannelsFlag: 0 + m_UpdateRectTransformForStandalone: 0 + m_SortingLayerID: 0 + m_SortingOrder: 0 + m_TargetDisplay: 0 --- !u!1 &333752980 GameObject: m_ObjectHideFlags: 0 @@ -429,7 +532,8 @@ RectTransform: m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 0, y: 0, z: 0} m_ConstrainProportionsScale: 0 - m_Children: [] + m_Children: + - {fileID: 241685776} m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} @@ -441,7 +545,7 @@ RectTransform: SceneRoots: m_ObjectHideFlags: 0 m_Roots: - - {fileID: 333752983} - {fileID: 271965289} + - {fileID: 333752983} - {fileID: 1867732347} - {fileID: 740636831} diff --git a/Assets/Script/Game/GameManager.cs b/Assets/Script/Game/GameManager.cs index aa577a6..6ea753f 100644 --- a/Assets/Script/Game/GameManager.cs +++ b/Assets/Script/Game/GameManager.cs @@ -4,7 +4,6 @@ using UnityEngine.SceneManagement; using System.Collections; using System.Collections.Generic; -[RequireComponent(typeof(Canvas))] public class GameManager : Singleton { [SerializeField] private GameObject mainPanel; @@ -17,6 +16,8 @@ public class GameManager : Singleton [SerializeField] private GameObject giboPanel; [SerializeField] private GameObject loadingPanel; + private LoadingPanelController loadingPanelController; + private UserManager _userManager; // UserManager 인스턴스 관리 private CoinsPanelController _coinsPanel; @@ -27,8 +28,8 @@ public class GameManager : Singleton private Canvas _canvas; public Sprite[] profileSprites; //패널에서 사용할 테스트 배열 - - private void Awake() + + private void Start() { // UserManager가 없으면 생성 if (UserManager.Instance == null) @@ -39,20 +40,16 @@ public class GameManager : Singleton //게임 씬에서 확인하기 위한 임시 코드 _gameType = Enums.GameType.SinglePlay; - } - - private void Start() - { + if (_canvas == null) { _canvas = GameObject.Find("Canvas").GetComponent(); } // 로딩 화면 추가(자동 로그인 응답 전까지) - OpenLoadingPanel(false, true, true); - loadingPanel.SetActive(true); + OpenLoadingPanel(false, false, true); // 자동 로그인 - // TryAutoSignin(); + TryAutoSignin(); //게임 씬에서 확인하기 위한 임시 코드 // _canvas = canvas.GetComponent(); @@ -67,33 +64,24 @@ public class GameManager : Singleton NetworkManager.Instance.GetInfo((userInfo) => { Debug.Log("자동 로그인 성공"); - StartCoroutine(WaitForLoading(userInfo)); - // loadingPanel.SetActive(false); - // UserManager.Instance.SetUserInfo(userInfo); - // - // UpdateMainPanelUI(OpenMainPanel); - // // ScoreData.SetScore(userInfo.score); - // OpenConfirmPanel(userInfo.nickname + "님" + "\n" + "자동 로그인 되었습니다", () => { }); + UserManager.Instance.SetUserInfo(userInfo); + + UpdateMainPanelUI(OpenMainPanel); + // ScoreData.SetScore(userInfo.score); + OpenConfirmPanel(userInfo.nickname + "님" + "\n" + "자동 로그인 되었습니다", () => { }); + + loadingPanelController.StopLoading(); }, () => { Debug.Log("자동 로그인 실패"); - loadingPanel.SetActive(false); + // 로딩 멈추기 + loadingPanelController.StopLoading(); // 로그인 화면 OpenSigninPanel(); }); } - private IEnumerator WaitForLoading(UserInfoResult userInfo) - { - yield return new WaitForSeconds(2f); - loadingPanel.SetActive(false); - UserManager.Instance.SetUserInfo(userInfo); - - UpdateMainPanelUI(OpenMainPanel); - // ScoreData.SetScore(userInfo.score); - OpenConfirmPanel(userInfo.nickname + "님" + "\n" + "자동 로그인 되었습니다", () => { }); - } /// /// 유저 별명, 급수를 서버에서 가져온 정보로 업데이트하여 메인화면에 표시 @@ -133,10 +121,10 @@ public class GameManager : Singleton var loadingPanelObject = Instantiate(loadingPanel, _canvas.transform); // 로딩 화면이 생성된 후, 원하는 애니메이션 활성화 - LoadingPanelController loadingPanelController = loadingPanelObject.GetComponent(); + loadingPanelController = loadingPanelObject.GetComponent(); if (loadingPanelController != null) { - loadingPanelController.SetAnimation(rotateImage, animatedText, flipImage); + loadingPanelController.StartLoading(rotateImage, animatedText, flipImage); } } } diff --git a/Assets/Script/Main/LoadingPanelController.cs b/Assets/Script/Main/LoadingPanelController.cs index 89292a6..1388551 100644 --- a/Assets/Script/Main/LoadingPanelController.cs +++ b/Assets/Script/Main/LoadingPanelController.cs @@ -1,5 +1,6 @@ using System.Collections; using System.Collections.Generic; +using System.Threading; using DG.Tweening; using TMPro; using UnityEngine; @@ -20,10 +21,15 @@ public class LoadingPanelController : MonoBehaviour [SerializeField] float delayBetweenFlips = 1f; // 이미지 변경 주기 private int currentLength = 0; + private CancellationTokenSource cancellationTokenSource; // 타 컴포넌트에서 애니메이션 효과 설정을 위해 호출(RotateImages와 FlipImages 혼용은 불가능: DORotate가 서로 충돌함) - public void SetAnimation(bool animatedImage, bool animatedText, bool animatedFlip) + public void StartLoading(bool animatedImage, bool animatedText, bool animatedFlip) { + // 패널 활성화 + gameObject.SetActive(true); + cancellationTokenSource = new CancellationTokenSource(); + if (animatedImage) RotateImages(); // 캐릭터들이 좌우로 회전하는 효과 if (animatedText) StartCoroutine(AnimateLoadingText()); // 한글자씩 나타나는 효과 if (animatedFlip) FlipImages(); // 캐릭터들이 뒤집히면서 표정이 바뀌는 효과 @@ -54,7 +60,7 @@ public class LoadingPanelController : MonoBehaviour // 한글자씩 나타나는 효과 private IEnumerator AnimateLoadingText() { - while (true) + while (!cancellationTokenSource.IsCancellationRequested) { // 글자 하나씩 추가 currentLength = (currentLength + 1) % (fullText.Length + 1); // 글자 하나씩 추가 (0 ~ fullText.Length 반복) @@ -85,7 +91,7 @@ public class LoadingPanelController : MonoBehaviour { var imageComponent = component.gameObject.GetComponent(); - while (true) + while (!cancellationTokenSource.IsCancellationRequested) { yield return new WaitForSeconds(delayBetweenFlips); @@ -106,4 +112,14 @@ public class LoadingPanelController : MonoBehaviour .WaitForCompletion(); } } + + public void StopLoading() + { + // 코루틴 취소 + if (cancellationTokenSource != null) + { + cancellationTokenSource.Cancel(); + } + gameObject.SetActive(false); + } }