From cce7aaa3b7736296b97854a21340a90831bdb113 Mon Sep 17 00:00:00 2001 From: Rafael Correa Date: Thu, 10 Dec 2020 22:31:53 -0300 Subject: [PATCH] Add FPS Stats and Remove lights --- Assets/Scenes/Main.unity | 341 ++++++++++++------ Assets/Scripts/Actors/OpenKnife.Actors.asmdef | 3 +- Assets/Scripts/Actors/Scorer.cs | 6 + Assets/Scripts/Actors/Shooter.cs | 3 +- Assets/Scripts/Levels/LevelManager.cs | 28 +- Assets/Scripts/Levels/OpenKnife.Levels.asmdef | 5 +- Assets/Scripts/UI/OpenKnife.UI.asmdef | 3 +- Assets/Scripts/UI/UIManager.cs | 30 ++ Assets/Scripts/Utils/FPSStat.cs | 69 ++++ Assets/Scripts/Utils/FPSStat.cs.meta | 11 + Assets/Settings/ForwardRenderer.asset | 2 + Assets/Settings/UniversalRP-LowQuality.asset | 6 +- ProjectSettings/ProjectSettings.asset | 2 +- ProjectSettings/QualitySettings.asset | 6 +- README.md | 2 +- 15 files changed, 376 insertions(+), 141 deletions(-) create mode 100644 Assets/Scripts/Utils/FPSStat.cs create mode 100644 Assets/Scripts/Utils/FPSStat.cs.meta diff --git a/Assets/Scenes/Main.unity b/Assets/Scenes/Main.unity index 79826d1..1281e99 100644 --- a/Assets/Scenes/Main.unity +++ b/Assets/Scenes/Main.unity @@ -37,7 +37,7 @@ RenderSettings: m_ReflectionBounces: 1 m_ReflectionIntensity: 1 m_CustomReflection: {fileID: 0} - m_Sun: {fileID: 2138677392} + m_Sun: {fileID: 0} m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1} m_UseRadianceAmbientProbe: 0 --- !u!157 &3 @@ -765,8 +765,9 @@ RectTransform: - {fileID: 1675849642} - {fileID: 1054862675} - {fileID: 1578136682} + - {fileID: 1629860501} m_Father: {fileID: 0} - m_RootOrder: 4 + m_RootOrder: 3 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} @@ -1387,6 +1388,162 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1054862674} m_CullTransparentMesh: 0 +--- !u!1 &1153130456 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1153130457} + - component: {fileID: 1153130459} + - component: {fileID: 1153130458} + m_Layer: 5 + m_Name: FPS Text + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1153130457 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1153130456} + 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_Children: [] + m_Father: {fileID: 1629860501} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 0} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 16} + m_Pivot: {x: 0.5, y: 0} +--- !u!114 &1153130458 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1153130456} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 0.79510856, b: 0, a: 1} + m_RaycastTarget: 1 + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 12800000, guid: 585188cdc4600544eb408bee749e4b3a, type: 3} + m_FontSize: 16 + m_FontStyle: 0 + m_BestFit: 0 + m_MinSize: 1 + m_MaxSize: 40 + m_Alignment: 5 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: 60 FPS +--- !u!222 &1153130459 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1153130456} + m_CullTransparentMesh: 0 +--- !u!1 &1176745979 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1176745980} + - component: {fileID: 1176745982} + - component: {fileID: 1176745981} + m_Layer: 5 + m_Name: MS Text) + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1176745980 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1176745979} + 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_Children: [] + m_Father: {fileID: 1629860501} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 16} + m_Pivot: {x: 0.5, y: 1} +--- !u!114 &1176745981 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1176745979} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 0.79510856, b: 0, a: 1} + m_RaycastTarget: 1 + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 12800000, guid: 585188cdc4600544eb408bee749e4b3a, type: 3} + m_FontSize: 16 + m_FontStyle: 0 + m_BestFit: 0 + m_MinSize: 1 + m_MaxSize: 40 + m_Alignment: 5 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: 60 MS +--- !u!222 &1176745982 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1176745979} + m_CullTransparentMesh: 0 --- !u!1 &1234645518 GameObject: m_ObjectHideFlags: 0 @@ -1547,7 +1704,7 @@ Transform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 7 + m_RootOrder: 6 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!114 &1248504425 MonoBehaviour: @@ -1561,7 +1718,12 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 3c1d1758e9fbac04e8790a792e44072d, type: 3} m_Name: m_EditorClassIdentifier: - levelManager: {fileID: 0} + m_ShootEvent: + m_PersistentCalls: + m_Calls: [] + m_NewShoots: + m_PersistentCalls: + m_Calls: [] mover: {fileID: 0} speedShooter: 256 --- !u!114 &1248504426 @@ -1812,7 +1974,7 @@ Transform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 6 + m_RootOrder: 5 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &1531396671 GameObject: @@ -2043,6 +2205,68 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1587762404} m_CullTransparentMesh: 0 +--- !u!1 &1629860500 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1629860501} + - component: {fileID: 1629860504} + - component: {fileID: 1629860502} + m_Layer: 5 + m_Name: FPS Stats + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1629860501 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1629860500} + 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_Children: + - {fileID: 1153130457} + - {fileID: 1176745980} + m_Father: {fileID: 530139049} + m_RootOrder: 3 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 1, y: 0} + m_AnchorMax: {x: 1, y: 0} + m_AnchoredPosition: {x: -8, y: 0} + m_SizeDelta: {x: 64, y: 32} + m_Pivot: {x: 1, y: 0} +--- !u!114 &1629860502 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1629860500} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: c7c57ccb0d1191b44806d6f2b0e0c626, type: 3} + m_Name: + m_EditorClassIdentifier: + UpdateInterval: 0.5 + _infoFPS: {fileID: 1153130458} + _infoMS: {fileID: 1176745981} +--- !u!222 &1629860504 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1629860500} + m_CullTransparentMesh: 0 --- !u!1 &1675849641 GameObject: m_ObjectHideFlags: 0 @@ -2238,7 +2462,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: a79441f348de89743a2939f4d699eac1, type: 3} m_Name: m_EditorClassIdentifier: - m_RenderShadows: 1 + m_RenderShadows: 0 m_RequiresDepthTextureOption: 2 m_RequiresOpaqueTextureOption: 2 m_CameraType: 0 @@ -2246,10 +2470,10 @@ MonoBehaviour: m_RendererIndex: -1 m_VolumeLayerMask: serializedVersion: 2 - m_Bits: 1 + m_Bits: 0 m_VolumeTrigger: {fileID: 0} - m_RenderPostProcessing: 1 - m_Antialiasing: 1 + m_RenderPostProcessing: 0 + m_Antialiasing: 0 m_AntialiasingQuality: 2 m_StopNaN: 0 m_Dithering: 0 @@ -2352,7 +2576,7 @@ Transform: - {fileID: 723958338} - {fileID: 734744214} m_Father: {fileID: 0} - m_RootOrder: 2 + m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!114 &1725963189 MonoBehaviour: @@ -2529,7 +2753,7 @@ Transform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 3 + m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!114 &1867632156 MonoBehaviour: @@ -2543,7 +2767,6 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: e0db28ef05bcf3f4f9a187b069083047, type: 3} m_Name: m_EditorClassIdentifier: - UI: {fileID: 530139050} onStartGame: m_PersistentCalls: m_Calls: @@ -2918,100 +3141,8 @@ Transform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 5 + m_RootOrder: 4 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!1 &2138677391 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 2138677393} - - component: {fileID: 2138677392} - m_Layer: 0 - m_Name: Directional Light - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!108 &2138677392 -Light: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 2138677391} - m_Enabled: 1 - serializedVersion: 10 - m_Type: 1 - m_Shape: 0 - m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1} - m_Intensity: 2 - m_Range: 10 - m_SpotAngle: 30 - m_InnerSpotAngle: 21.802082 - m_CookieSize: 10 - m_Shadows: - m_Type: 2 - m_Resolution: -1 - m_CustomResolution: -1 - m_Strength: 1 - m_Bias: 0.02 - m_NormalBias: 0.1 - m_NearPlane: 0.1 - m_CullingMatrixOverride: - e00: 1 - e01: 0 - e02: 0 - e03: 0 - e10: 0 - e11: 1 - e12: 0 - e13: 0 - e20: 0 - e21: 0 - e22: 1 - e23: 0 - e30: 0 - e31: 0 - e32: 0 - e33: 1 - m_UseCullingMatrixOverride: 0 - m_Cookie: {fileID: 0} - m_DrawHalo: 0 - m_Flare: {fileID: 0} - m_RenderMode: 0 - m_CullingMask: - serializedVersion: 2 - m_Bits: 4294967295 - m_RenderingLayerMask: 1 - m_Lightmapping: 4 - m_LightShadowCasterMode: 0 - m_AreaSize: {x: 1, y: 1} - m_BounceIntensity: 1 - m_ColorTemperature: 6570 - m_UseColorTemperature: 0 - m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0} - m_UseBoundingSphereOverride: 0 - m_ShadowRadius: 0 - m_ShadowAngle: 0 ---- !u!4 &2138677393 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 2138677391} - m_LocalRotation: {x: 0.7064338, y: 0.47771442, z: 0.030843567, w: 0.5213338} - m_LocalPosition: {x: 0.24, y: 3, z: 4.18} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 0} - m_RootOrder: 1 - m_LocalEulerAnglesHint: {x: 45, y: 130, z: 90} --- !u!1 &2138747837 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/Actors/OpenKnife.Actors.asmdef b/Assets/Scripts/Actors/OpenKnife.Actors.asmdef index 76c240a..cb19316 100644 --- a/Assets/Scripts/Actors/OpenKnife.Actors.asmdef +++ b/Assets/Scripts/Actors/OpenKnife.Actors.asmdef @@ -2,8 +2,7 @@ "name": "OpenKnife.Actors", "references": [ "OpenKnife.Utils", - "OpenKnife", - "OpenKnife.UI" + "OpenKnife" ], "includePlatforms": [], "excludePlatforms": [], diff --git a/Assets/Scripts/Actors/Scorer.cs b/Assets/Scripts/Actors/Scorer.cs index 420e955..8920c58 100644 --- a/Assets/Scripts/Actors/Scorer.cs +++ b/Assets/Scripts/Actors/Scorer.cs @@ -10,6 +10,12 @@ public class Scorer : MonoBehaviour public int Score => score; public int Fruits => fruits; + private void Start() + { + score = 0; + fruits = 0; + } + public void AddScore(int value) { if (value < 0) return; diff --git a/Assets/Scripts/Actors/Shooter.cs b/Assets/Scripts/Actors/Shooter.cs index 6084baa..5cee3fd 100644 --- a/Assets/Scripts/Actors/Shooter.cs +++ b/Assets/Scripts/Actors/Shooter.cs @@ -1,6 +1,5 @@ using UnityEngine; using OpenKnife; -using OpenKnife.UI; using UnityEngine.Events; namespace OpenKnife.Actors @@ -16,6 +15,7 @@ public class Shooter : MonoBehaviour { private int shoots = 0; public ShootEvent m_ShootEvent = new ShootEvent(); + public ShootEvent m_NewShoots = new ShootEvent(); public ConstantForce2D mover; @@ -27,7 +27,6 @@ public class Shooter : MonoBehaviour public void SetNewShoots(int shoots) { this.shoots = shoots; - UIManager.instance.shootsPanel.SetNewShoots(shoots); } private void Update() diff --git a/Assets/Scripts/Levels/LevelManager.cs b/Assets/Scripts/Levels/LevelManager.cs index 8839e22..e952b0e 100644 --- a/Assets/Scripts/Levels/LevelManager.cs +++ b/Assets/Scripts/Levels/LevelManager.cs @@ -4,10 +4,10 @@ using UnityEngine.Events; using OpenKnife.Actors; using OpenKnife.States; -using OpenKnife.UI; namespace OpenKnife.Levels { + public class LevelManager : MonoBehaviour, GameStates { #region Public variables @@ -25,7 +25,6 @@ public class LevelManager : MonoBehaviour, GameStates public GameObject wood; public Transform spawnShooter; - [Header("Events")] public UnityEvent onKnifeHitOnWood; public UnityEvent onKnifeHitOnKnife; @@ -35,6 +34,11 @@ public class LevelManager : MonoBehaviour, GameStates public UnityEvent onStageFinish; public UnityEvent onShoot; + public int ActualStage => actualStage; + public int ActualScore => scorer.Score; + public int Fruits => scorer.Fruits; + public int Shoots => shooter.Shoots; + #endregion #region Private variables @@ -134,26 +138,9 @@ private void InitBuiltInEvents() Destroy(go, 1f); scorer.AddFruits(1); - UIManager.instance.UpdateFruitsText(scorer.Fruits); - }); - onScore.AddListener(delegate - { - UIManager.instance.UpdateScoreText(scorer.Score); }); - onStageInit.AddListener(delegate - { - UIManager.instance.UpdateStageTitleText(actualStage); - }); - onStageFinish.AddListener(delegate - { - UIManager.instance.stageTitle.gameObject.SetActive(false); - }); - - onShoot.AddListener(delegate - { - UIManager.instance.shootsPanel.Shoot(); - }); + } // Prepare for next shooter @@ -201,7 +188,6 @@ private void RequestNewShoot() private void Next() { actualStage++; - UIManager.instance.UpdateStageText(actualStage); if (stages.Length <= actualStage) { GameManager.instance.GameOver(); diff --git a/Assets/Scripts/Levels/OpenKnife.Levels.asmdef b/Assets/Scripts/Levels/OpenKnife.Levels.asmdef index cfe191a..f701745 100644 --- a/Assets/Scripts/Levels/OpenKnife.Levels.asmdef +++ b/Assets/Scripts/Levels/OpenKnife.Levels.asmdef @@ -1,10 +1,9 @@ { "name": "OpenKnife.Levels", "references": [ - "OpenKnife.Actors", - "OpenKnife.States", "OpenKnife", - "OpenKnife.UI" + "OpenKnife.Actors", + "OpenKnife.States" ], "includePlatforms": [], "excludePlatforms": [], diff --git a/Assets/Scripts/UI/OpenKnife.UI.asmdef b/Assets/Scripts/UI/OpenKnife.UI.asmdef index 51e2b56..f17ec7d 100644 --- a/Assets/Scripts/UI/OpenKnife.UI.asmdef +++ b/Assets/Scripts/UI/OpenKnife.UI.asmdef @@ -3,7 +3,8 @@ "references": [ "OpenKnife.States", "OpenKnife", - "UnityEngine.UI" + "UnityEngine.UI", + "OpenKnife.Levels" ], "includePlatforms": [], "excludePlatforms": [], diff --git a/Assets/Scripts/UI/UIManager.cs b/Assets/Scripts/UI/UIManager.cs index 8d422b1..0c484e0 100644 --- a/Assets/Scripts/UI/UIManager.cs +++ b/Assets/Scripts/UI/UIManager.cs @@ -3,6 +3,7 @@ using OpenKnife.States; using UnityEngine; using UnityEngine.UI; +using OpenKnife.Levels; namespace OpenKnife.UI { @@ -15,6 +16,8 @@ public class UIManager : MonoBehaviour, GameStates public GameObject inGamePanel; public GameObject gameOverPanel; + private LevelManager levelManager; + [Header("References")] public Text stageText; public Text fruitsText; @@ -36,10 +39,37 @@ private void Awake() private void Start() { + levelManager = GameManager.instance.GetComponent(); GameManager.instance.gameStates.Add(this); UpdateFruitsText(0); UpdateScoreText(0); UpdateStageText(0); + + levelManager.onShoot.AddListener(delegate + { + shootsPanel.Shoot(); + }); + levelManager.onStageFinish.AddListener(delegate + { + stageTitle.gameObject.SetActive(false); + }); + levelManager.onStageInit.AddListener(delegate + { + UpdateStageTitleText(levelManager.ActualStage); + shootsPanel.SetNewShoots(levelManager.Shoots); + }); + levelManager.onScore.AddListener(delegate + { + UpdateScoreText(levelManager.ActualScore); + }); + levelManager.onStageInit.AddListener(delegate + { + UpdateStageText(levelManager.ActualStage); + }); + levelManager.onFruitSlice.AddListener(delegate + { + UpdateFruitsText(levelManager.Fruits); + }); } private void OnDisable() diff --git a/Assets/Scripts/Utils/FPSStat.cs b/Assets/Scripts/Utils/FPSStat.cs new file mode 100644 index 0000000..23f1213 --- /dev/null +++ b/Assets/Scripts/Utils/FPSStat.cs @@ -0,0 +1,69 @@ +using UnityEngine; +using UnityEngine.UI; + +namespace OpenKnife.Utils +{ + public class FPSStat : MonoBehaviour + { + + [Range(0.1f,1f)] + public float UpdateInterval = 0.5f; + + public Text _infoFPS; + public Text _infoMS; + + private float m_AccumulatedTime = 0f; + private int m_AccumulatedFrames = 0; + private float m_LastUpdateTime; + private float m_FrameTime = 0f; + private float m_FrameRate = 0f; + + public static float MinTime = 0.000000001f; + + private void Update() + { + float deltaTime = Time.unscaledDeltaTime; + + m_AccumulatedTime += deltaTime; + m_AccumulatedFrames++; + + float nowTime = Time.realtimeSinceStartup; + if (nowTime - m_LastUpdateTime < UpdateInterval) { + return; + } + + m_FrameTime = m_AccumulatedTime / m_AccumulatedFrames; + m_FrameRate = 1.0f / m_FrameTime; + + UpdateInfo(); + + ResetProbingData(); + m_LastUpdateTime = nowTime; + } + + + private void UpdateInfo() + { + _infoFPS.text = string.Format( + "{0}"+" FPS ", + m_FrameRate.ToString("F0")); + + _infoMS.text = string.Format( + "{0}"+" MS ", + (m_FrameTime*1000f).ToString("F1")); + } + + + private void ResetProbingData() { + m_AccumulatedTime = 0.0f; + m_AccumulatedFrames = 0; + } + + private void Reset() + { + m_LastUpdateTime = Time.realtimeSinceStartup; + } + + + } +} \ No newline at end of file diff --git a/Assets/Scripts/Utils/FPSStat.cs.meta b/Assets/Scripts/Utils/FPSStat.cs.meta new file mode 100644 index 0000000..da92c91 --- /dev/null +++ b/Assets/Scripts/Utils/FPSStat.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c7c57ccb0d1191b44806d6f2b0e0c626 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Settings/ForwardRenderer.asset b/Assets/Settings/ForwardRenderer.asset index 4514a2b..881268d 100644 --- a/Assets/Settings/ForwardRenderer.asset +++ b/Assets/Settings/ForwardRenderer.asset @@ -13,6 +13,7 @@ MonoBehaviour: m_Name: ForwardRenderer m_EditorClassIdentifier: m_RendererFeatures: [] + m_RendererFeatureMap: postProcessData: {fileID: 11400000, guid: 41439944d30ece34e96484bdb6645b55, type: 2} shaders: blitPS: {fileID: 4800000, guid: c17132b1f77d20942aa75f8429c0f8bc, type: 3} @@ -34,3 +35,4 @@ MonoBehaviour: passOperation: 0 failOperation: 0 zFailOperation: 0 + m_ShadowTransparentReceive: 0 diff --git a/Assets/Settings/UniversalRP-LowQuality.asset b/Assets/Settings/UniversalRP-LowQuality.asset index ab81d03..800fc23 100644 --- a/Assets/Settings/UniversalRP-LowQuality.asset +++ b/Assets/Settings/UniversalRP-LowQuality.asset @@ -22,10 +22,11 @@ MonoBehaviour: m_RequireDepthTexture: 0 m_RequireOpaqueTexture: 0 m_OpaqueDownsampling: 1 + m_SupportsTerrainHoles: 0 m_SupportsHDR: 0 m_MSAA: 1 m_RenderScale: 1 - m_MainLightRenderingMode: 1 + m_MainLightRenderingMode: 0 m_MainLightShadowsSupported: 0 m_MainLightShadowmapResolution: 2048 m_AdditionalLightsRenderingMode: 0 @@ -41,8 +42,9 @@ MonoBehaviour: m_SoftShadowsSupported: 0 m_UseSRPBatcher: 1 m_SupportsDynamicBatching: 0 - m_MixedLightingSupported: 1 + m_MixedLightingSupported: 0 m_DebugLevel: 0 + m_PostProcessingFeatureSet: 0 m_ColorGradingMode: 0 m_ColorGradingLutSize: 16 m_ShadowType: 1 diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset index 7e6d918..7e9d415 100644 --- a/ProjectSettings/ProjectSettings.asset +++ b/ProjectSettings/ProjectSettings.asset @@ -126,7 +126,7 @@ PlayerSettings: 16:10: 1 16:9: 1 Others: 1 - bundleVersion: 0.2.21 + bundleVersion: 0.2.5 preloadedAssets: [] metroInputSource: 0 wsaTransparentSwapchain: 0 diff --git a/ProjectSettings/QualitySettings.asset b/ProjectSettings/QualitySettings.asset index cab35cc..96c94c8 100644 --- a/ProjectSettings/QualitySettings.asset +++ b/ProjectSettings/QualitySettings.asset @@ -4,7 +4,7 @@ QualitySettings: m_ObjectHideFlags: 0 serializedVersion: 5 - m_CurrentQuality: 2 + m_CurrentQuality: 0 m_QualitySettings: - serializedVersion: 2 name: Low @@ -118,13 +118,13 @@ QualitySettings: type: 2} excludedTargetPlatforms: [] m_PerPlatformDefaultQuality: - Android: 1 + Android: 0 Lumin: 2 Nintendo Switch: 2 PS4: 2 Stadia: 2 Standalone: 2 - WebGL: 1 + WebGL: 0 Windows Store Apps: 2 XboxOne: 2 iPhone: 1 diff --git a/README.md b/README.md index 19c95a0..c9f03dc 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # OpenKnife # Bem-vindo ao Open Knife 👋 -![Version](https://img.shields.io/badge/version-0.2.2-blue.svg?cacheSeconds=2592000) +![Version](https://img.shields.io/badge/version-0.2.5-blue.svg?cacheSeconds=2592000) [![Documentation](https://img.shields.io/badge/documentation-yes-brightgreen.svg)](todo-doc) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](MIT) [![Twitter: ScriptsEngineer](https://img.shields.io/twitter/follow/ScriptsEngineer.svg?style=social)](https://twitter.com/ScriptsEngineer)