From b1afc0b171fe2433177563b132daeb729ff7ef24 Mon Sep 17 00:00:00 2001 From: qoralstmd6825 Date: Tue, 3 Feb 2026 22:18:08 +0900 Subject: [PATCH] =?UTF-8?q?=EB=A1=9C=ED=94=84=20=EB=B0=98=EB=8F=99,=20FPS?= =?UTF-8?q?=20UI=20=ED=91=9C=EC=8B=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Scenes/DemoScene.unity | 95 +++++++++++++++++++++++++ Assets/Scripts/LevelManager.cs | 94 ++++++++++++++++++++++++ Assets/Scripts/Player/PlayerMovement.cs | 3 +- Assets/Scripts/UpdateFpsUI.cs | 31 ++++++++ 4 files changed, 222 insertions(+), 1 deletion(-) create mode 100644 Assets/Scripts/LevelManager.cs create mode 100644 Assets/Scripts/UpdateFpsUI.cs diff --git a/Assets/Scenes/DemoScene.unity b/Assets/Scenes/DemoScene.unity index 18b1862..30427bc 100644 --- a/Assets/Scenes/DemoScene.unity +++ b/Assets/Scenes/DemoScene.unity @@ -293,6 +293,7 @@ RectTransform: m_ConstrainProportionsScale: 0 m_Children: - {fileID: 1157925016} + - {fileID: 1471101855} m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} @@ -667,6 +668,100 @@ Transform: m_Children: [] m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &1471101854 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1471101855} + - component: {fileID: 1471101857} + - component: {fileID: 1471101856} + - component: {fileID: 1471101858} + m_Layer: 5 + m_Name: FpsText + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1471101855 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1471101854} + 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: 285871627} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 1, y: 1} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: -110, y: -45} + m_SizeDelta: {x: 160, y: 30} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1471101856 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1471101854} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.Text + m_Material: {fileID: 0} + m_Color: {r: 0, g: 0, b: 0, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 40 + m_FontStyle: 1 + m_BestFit: 0 + m_MinSize: 1 + m_MaxSize: 100 + m_Alignment: 2 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 1 + m_VerticalOverflow: 1 + m_LineSpacing: 1 + m_Text: 'fps : 60' +--- !u!222 &1471101857 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1471101854} + m_CullTransparentMesh: 1 +--- !u!114 &1471101858 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1471101854} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 0b7b9ee9f8858004c8defe87c1d6f448, type: 3} + m_Name: + m_EditorClassIdentifier: Assembly-CSharp::UpdateFpsUI + fps: 0 + fpsText: {fileID: 1471101856} --- !u!1 &1712523066 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/LevelManager.cs b/Assets/Scripts/LevelManager.cs new file mode 100644 index 0000000..5b721c0 --- /dev/null +++ b/Assets/Scripts/LevelManager.cs @@ -0,0 +1,94 @@ +using System.Collections; +using UnityEngine; +using UnityEngine.SceneManagement; + +public class LevelManager : MonoBehaviour +{ + public static LevelManager instance; + + public enum GameState { Ready, Playing, GameOver} + + public GameState CurrentGameState { get; private set; } + public Transform CameraTarget { get; private set; } + + [SerializeField] private float timeLimit; + [SerializeField] private int replayCounts; + + [SerializeField] private Transform cheesePosition; + [SerializeField] private Transform playerPosition; + + private float currentTimer; + + + + void Awake() + { + DontDestroyOnLoad(gameObject); + if (instance == null) + { + instance = this; + } + else + { + Destroy(gameObject); + } + } + + void Start() + { + StartCoroutine(LevelStart()); + } + + private void Update() + { + if (CurrentGameState == GameState.Playing) + { + UpdateTimer(); + } + } + + private void UpdateTimer() + { + currentTimer += Time.deltaTime; + if(currentTimer > timeLimit) + { + replayCounts--; + if (replayCounts > 0) + { + RecordingManager.instance.StopPlayingRecord(); + } + else + { + CurrentGameState = GameState.GameOver; + } + } + } + + private void InitTimer() + { + currentTimer = 0; + } + + private IEnumerator LevelStart() + { + CurrentGameState = GameState.Ready; + yield return new WaitForSeconds(1f); + + CameraTarget = cheesePosition; + yield return new WaitForSeconds(2f); + + CameraTarget = playerPosition; + yield return new WaitForSeconds(1f); + CurrentGameState = GameState.Playing; + } + + public void OnTakeCheese() + { + + } + + private void LoadNextLevel() + { + + } +} diff --git a/Assets/Scripts/Player/PlayerMovement.cs b/Assets/Scripts/Player/PlayerMovement.cs index 6235b05..327db49 100644 --- a/Assets/Scripts/Player/PlayerMovement.cs +++ b/Assets/Scripts/Player/PlayerMovement.cs @@ -98,13 +98,14 @@ public class PlayerMovement : MonoBehaviour { isHanging = false; _rigidbody2D.bodyType = RigidbodyType2D.Dynamic; - hangingWallRigidBody = null; if (hangingWallCollider != null) { Physics2D.IgnoreCollision(_collider2D, hangingWallCollider, false); hangingWallCollider = null; } transform.SetParent(null, true); + _rigidbody2D.linearVelocity = hangingWallRigidBody.linearVelocity * 4; + hangingWallRigidBody = null; } private void HangingObject() diff --git a/Assets/Scripts/UpdateFpsUI.cs b/Assets/Scripts/UpdateFpsUI.cs new file mode 100644 index 0000000..c1eeb83 --- /dev/null +++ b/Assets/Scripts/UpdateFpsUI.cs @@ -0,0 +1,31 @@ +using UnityEngine; +using UnityEngine.UI; + +public class UpdateFpsUI : MonoBehaviour +{ + private Text fpsText; + + private float frameCount = 0; + private float deltaTime = 0f; + private float fps = 0f; + + void Start() + { + fpsText = transform.GetComponent(); + } + + void Update() + { + Debug.Log("Test"); + frameCount++; + deltaTime += Time.unscaledDeltaTime; + if (deltaTime > 1) + { + fps = frameCount / deltaTime; + fpsText.text = $"fps : {Mathf.Round(fps)}"; + + frameCount = 0; + deltaTime = 0f; + } + } +}