Commit 67e6bf7c authored by Martin Mihálik's avatar Martin Mihálik 🔥
Browse files

Pausing

parent b3fd9bc4
......@@ -287,7 +287,7 @@ Transform:
m_Children:
- {fileID: 519420032}
m_Father: {fileID: 0}
m_RootOrder: 1
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &512397505
MonoBehaviour:
......@@ -528,6 +528,73 @@ Transform:
m_Children:
- {fileID: 1877781302}
m_Father: {fileID: 0}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1654006367
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1654006369}
- component: {fileID: 1654006368}
m_Layer: 0
m_Name: GameState
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1654006368
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1654006367}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fdc0f0ef9127c834abc75473807ed5a2, type: 3}
m_Name:
m_EditorClassIdentifier:
m_BeforePauseHooks:
m_PersistentCalls:
m_Calls: []
m_AfterPauseHooks:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 512397505}
m_TargetAssemblyTypeName: PlayerMovement, Assembly-CSharp
m_MethodName: OnPause
m_Mode: 1
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
m_BeforeResumeHooks:
m_PersistentCalls:
m_Calls: []
m_AfterResumeHooks:
m_PersistentCalls:
m_Calls: []
--- !u!4 &1654006369
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1654006367}
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: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1695424172
......@@ -562,7 +629,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 &1695424174
MonoBehaviour:
......@@ -1506,7 +1573,7 @@ Transform:
- {fileID: 106956313}
- {fileID: 792207690}
m_Father: {fileID: 0}
m_RootOrder: 2
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &2028534473
MonoBehaviour:
......
using UnityEngine;
using UnityEngine.Events;
public class PauseController : MonoBehaviour
{
[SerializeField] private UnityEvent m_BeforePauseHooks;
[SerializeField] private UnityEvent m_AfterPauseHooks;
[SerializeField] private UnityEvent m_BeforeResumeHooks;
[SerializeField] private UnityEvent m_AfterResumeHooks;
public bool Paused { get => Time.timeScale == 0; }
private void Update()
{
if (Input.GetKeyDown(KeyCode.P))
{
if (Paused)
{
Resume();
}
else
{
Pause();
}
}
}
public void Pause()
{
m_BeforePauseHooks.Invoke();
Time.timeScale = 0;
m_AfterPauseHooks.Invoke();
}
public void Resume()
{
m_BeforeResumeHooks.Invoke();
Time.timeScale = 1;
m_AfterResumeHooks.Invoke();
}
}
fileFormatVersion: 2
guid: fdc0f0ef9127c834abc75473807ed5a2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment