From cff7439413a98ea8d566b94de4119a0b69fa786d Mon Sep 17 00:00:00 2001 From: Jens Pitkanen Date: Mon, 20 Apr 2020 05:42:36 +0300 Subject: [PATCH] Add quit button to pause menu and fix build --- Assets/Prefabs/UI/Pause Menu.prefab | 212 ++++++++++++++++++- Assets/Scripts/AssetModificationProcessor.cs | 2 + Assets/Scripts/PauseMenu.cs | 4 + 3 files changed, 215 insertions(+), 3 deletions(-) diff --git a/Assets/Prefabs/UI/Pause Menu.prefab b/Assets/Prefabs/UI/Pause Menu.prefab index 576c613..b68ac45 100644 --- a/Assets/Prefabs/UI/Pause Menu.prefab +++ b/Assets/Prefabs/UI/Pause Menu.prefab @@ -1,5 +1,134 @@ %YAML 1.1 %TAG !u! tag:unity3d.com,2011: +--- !u!1 &55738144867450552 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 8367774084993859881} + - component: {fileID: 1773797959613665485} + - component: {fileID: 5814793508332930773} + - component: {fileID: 3808715198819232677} + m_Layer: 5 + m_Name: Quit Button + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &8367774084993859881 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 55738144867450552} + 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: 2739971973133373400} + m_Father: {fileID: 6755247300797306272} + m_RootOrder: 3 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0} + m_AnchorMax: {x: 0.5, y: 0} + m_AnchoredPosition: {x: -20, y: 60} + m_SizeDelta: {x: 160, y: 50} + m_Pivot: {x: 1, y: 0.5} +--- !u!222 &1773797959613665485 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 55738144867450552} + m_CullTransparentMesh: 0 +--- !u!114 &5814793508332930773 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 55738144867450552} + 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: 0.8, g: 0.8, b: 0.8, a: 1} + m_RaycastTarget: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 10905, 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!114 &3808715198819232677 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 55738144867450552} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Navigation: + m_Mode: 3 + m_SelectOnUp: {fileID: 0} + m_SelectOnDown: {fileID: 0} + m_SelectOnLeft: {fileID: 0} + m_SelectOnRight: {fileID: 0} + m_Transition: 1 + m_Colors: + m_NormalColor: {r: 1, g: 1, b: 1, a: 1} + m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} + m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} + m_ColorMultiplier: 1 + m_FadeDuration: 0.1 + m_SpriteState: + m_HighlightedSprite: {fileID: 0} + m_PressedSprite: {fileID: 0} + m_SelectedSprite: {fileID: 0} + m_DisabledSprite: {fileID: 0} + m_AnimationTriggers: + m_NormalTrigger: Normal + m_HighlightedTrigger: Highlighted + m_PressedTrigger: Pressed + m_SelectedTrigger: Selected + m_DisabledTrigger: Disabled + m_Interactable: 1 + m_TargetGraphic: {fileID: 5814793508332930773} + m_OnClick: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 5400695020334462791} + m_MethodName: Quit + 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 --- !u!1 &113812485386852927 GameObject: m_ObjectHideFlags: 0 @@ -475,6 +604,7 @@ RectTransform: - {fileID: 5400695019851472732} - {fileID: 2316617036968199621} - {fileID: 2023163602813406806} + - {fileID: 8367774084993859881} m_Father: {fileID: 5400695020334462789} m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} @@ -2570,7 +2700,6 @@ MonoBehaviour: m_EditorClassIdentifier: GameState: {fileID: 0} Options: {fileID: 2837007226937140173} - InvertMouseX: {fileID: 0} InvertMouseY: {fileID: 3688206207163001157} CameraBobbing: {fileID: 2164472545587475712} MouseSensitivity: {fileID: 4413106551099451582} @@ -3692,9 +3821,9 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0} m_AnchorMax: {x: 0.5, y: 0} - m_AnchoredPosition: {x: 0, y: 60} + m_AnchoredPosition: {x: 20, y: 60} m_SizeDelta: {x: 160, y: 50} - m_Pivot: {x: 0.5, y: 0.5} + m_Pivot: {x: 0, y: 0.5} --- !u!222 &3618535302975715482 CanvasRenderer: m_ObjectHideFlags: 0 @@ -3785,6 +3914,83 @@ MonoBehaviour: m_StringArgument: m_BoolArgument: 0 m_CallState: 2 +--- !u!1 &9110732146301057963 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2739971973133373400} + - component: {fileID: 1828405766009577784} + - component: {fileID: 5259050888782707427} + m_Layer: 5 + m_Name: Text + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &2739971973133373400 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 9110732146301057963} + 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: 8367774084993859881} + m_RootOrder: 0 + 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!222 &1828405766009577784 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 9110732146301057963} + m_CullTransparentMesh: 0 +--- !u!114 &5259050888782707427 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 9110732146301057963} + 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: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} + m_RaycastTarget: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 12800000, guid: a0bb3d007c7133149bd1682bd93b776f, type: 3} + m_FontSize: 26 + m_FontStyle: 0 + m_BestFit: 0 + m_MinSize: 2 + m_MaxSize: 40 + m_Alignment: 4 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: Quit --- !u!1 &9138595278049255356 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/AssetModificationProcessor.cs b/Assets/Scripts/AssetModificationProcessor.cs index 2613e81..fe15ab0 100644 --- a/Assets/Scripts/AssetModificationProcessor.cs +++ b/Assets/Scripts/AssetModificationProcessor.cs @@ -1,6 +1,7 @@ using UnityEditor; using UnityEngine; +#if UNITY_EDITOR public class FGAssetModificationProcessor : UnityEditor.AssetModificationProcessor { static string[] OnWillSaveAssets(string[] paths) { foreach (GameObject obj in GameObject.FindGameObjectsWithTag("Generator")) { @@ -25,3 +26,4 @@ public class FGAssetModificationProcessor : UnityEditor.AssetModificationProcess } } } +#endif diff --git a/Assets/Scripts/PauseMenu.cs b/Assets/Scripts/PauseMenu.cs index d464dbf..f2ec37d 100644 --- a/Assets/Scripts/PauseMenu.cs +++ b/Assets/Scripts/PauseMenu.cs @@ -50,4 +50,8 @@ public class PauseMenu : MonoBehaviour { public void Resume() { GameState.Current = State.Playing; } + + public void Quit() { + Application.Quit(); + } }