feat: new ingame pause menu, with transition to main menu

This commit is contained in:
Jakob Feldmann 2024-04-17 00:52:58 +02:00
parent 0251cce123
commit a23b68cc51
29 changed files with 36246 additions and 243 deletions

View File

@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was auto-generated by com.unity.inputsystem:InputActionCodeGenerator
// version 1.6.3
// version 1.7.0
// from Assets/Input System Settings/InputActionMaps.inputactions
//
// Changes to this file may cause incorrect behavior and will be lost if
@ -45,15 +45,6 @@ public partial class @InputActionMaps: IInputActionCollection2, IDisposable
""interactions"": """",
""initialStateCheck"": true
},
{
""name"": ""Reset"",
""type"": ""Button"",
""id"": ""6ab0c9d5-b21f-4819-b5c8-ad277a1246c7"",
""expectedControlType"": ""Button"",
""processors"": """",
""interactions"": """",
""initialStateCheck"": false
},
{
""name"": ""Boost"",
""type"": ""PassThrough"",
@ -362,28 +353,6 @@ public partial class @InputActionMaps: IInputActionCollection2, IDisposable
""isComposite"": false,
""isPartOfComposite"": true
},
{
""name"": """",
""id"": ""8c09092a-7323-4f5c-80df-19bfe90a207c"",
""path"": ""<Keyboard>/r"",
""interactions"": """",
""processors"": """",
""groups"": ""Keyboard 1;Keyboard 2"",
""action"": ""Reset"",
""isComposite"": false,
""isPartOfComposite"": false
},
{
""name"": """",
""id"": ""b50ff906-5e23-4bd0-b5b7-98aeb46a2284"",
""path"": ""<Gamepad>/select"",
""interactions"": """",
""processors"": """",
""groups"": ""Controller"",
""action"": ""Reset"",
""isComposite"": false,
""isPartOfComposite"": false
},
{
""name"": """",
""id"": ""f76aad49-c115-4d72-a860-b674c8489543"",
@ -451,6 +420,15 @@ public partial class @InputActionMaps: IInputActionCollection2, IDisposable
""processors"": """",
""interactions"": """",
""initialStateCheck"": false
},
{
""name"": ""Reset"",
""type"": ""Button"",
""id"": ""476b1454-7144-4728-a5f3-3f98f839aeca"",
""expectedControlType"": ""Button"",
""processors"": """",
""interactions"": """",
""initialStateCheck"": false
}
],
""bindings"": [
@ -497,6 +475,28 @@ public partial class @InputActionMaps: IInputActionCollection2, IDisposable
""action"": ""Pause"",
""isComposite"": false,
""isPartOfComposite"": false
},
{
""name"": """",
""id"": ""2e99e546-209d-410c-9d54-3482c05d8e90"",
""path"": ""<Keyboard>/r"",
""interactions"": """",
""processors"": """",
""groups"": ""Keyboard 1;Keyboard 2"",
""action"": ""Reset"",
""isComposite"": false,
""isPartOfComposite"": false
},
{
""name"": """",
""id"": ""7e601b0a-6c05-4444-ac07-0e02fbf4b64b"",
""path"": ""<Gamepad>/select"",
""interactions"": """",
""processors"": """",
""groups"": ""Controller"",
""action"": ""Reset"",
""isComposite"": false,
""isPartOfComposite"": false
}
]
}
@ -546,12 +546,12 @@ public partial class @InputActionMaps: IInputActionCollection2, IDisposable
m_Player = asset.FindActionMap("Player", throwIfNotFound: true);
m_Player_Thrust = m_Player.FindAction("Thrust", throwIfNotFound: true);
m_Player_Steer = m_Player.FindAction("Steer", throwIfNotFound: true);
m_Player_Reset = m_Player.FindAction("Reset", throwIfNotFound: true);
m_Player_Boost = m_Player.FindAction("Boost", throwIfNotFound: true);
// Meta
m_Meta = asset.FindActionMap("Meta", throwIfNotFound: true);
m_Meta_Start = m_Meta.FindAction("Start", throwIfNotFound: true);
m_Meta_Pause = m_Meta.FindAction("Pause", throwIfNotFound: true);
m_Meta_Reset = m_Meta.FindAction("Reset", throwIfNotFound: true);
}
public void Dispose()
@ -615,7 +615,6 @@ public partial class @InputActionMaps: IInputActionCollection2, IDisposable
private List<IPlayerActions> m_PlayerActionsCallbackInterfaces = new List<IPlayerActions>();
private readonly InputAction m_Player_Thrust;
private readonly InputAction m_Player_Steer;
private readonly InputAction m_Player_Reset;
private readonly InputAction m_Player_Boost;
public struct PlayerActions
{
@ -623,7 +622,6 @@ public partial class @InputActionMaps: IInputActionCollection2, IDisposable
public PlayerActions(@InputActionMaps wrapper) { m_Wrapper = wrapper; }
public InputAction @Thrust => m_Wrapper.m_Player_Thrust;
public InputAction @Steer => m_Wrapper.m_Player_Steer;
public InputAction @Reset => m_Wrapper.m_Player_Reset;
public InputAction @Boost => m_Wrapper.m_Player_Boost;
public InputActionMap Get() { return m_Wrapper.m_Player; }
public void Enable() { Get().Enable(); }
@ -640,9 +638,6 @@ public partial class @InputActionMaps: IInputActionCollection2, IDisposable
@Steer.started += instance.OnSteer;
@Steer.performed += instance.OnSteer;
@Steer.canceled += instance.OnSteer;
@Reset.started += instance.OnReset;
@Reset.performed += instance.OnReset;
@Reset.canceled += instance.OnReset;
@Boost.started += instance.OnBoost;
@Boost.performed += instance.OnBoost;
@Boost.canceled += instance.OnBoost;
@ -656,9 +651,6 @@ public partial class @InputActionMaps: IInputActionCollection2, IDisposable
@Steer.started -= instance.OnSteer;
@Steer.performed -= instance.OnSteer;
@Steer.canceled -= instance.OnSteer;
@Reset.started -= instance.OnReset;
@Reset.performed -= instance.OnReset;
@Reset.canceled -= instance.OnReset;
@Boost.started -= instance.OnBoost;
@Boost.performed -= instance.OnBoost;
@Boost.canceled -= instance.OnBoost;
@ -685,12 +677,14 @@ public partial class @InputActionMaps: IInputActionCollection2, IDisposable
private List<IMetaActions> m_MetaActionsCallbackInterfaces = new List<IMetaActions>();
private readonly InputAction m_Meta_Start;
private readonly InputAction m_Meta_Pause;
private readonly InputAction m_Meta_Reset;
public struct MetaActions
{
private @InputActionMaps m_Wrapper;
public MetaActions(@InputActionMaps wrapper) { m_Wrapper = wrapper; }
public InputAction @Start => m_Wrapper.m_Meta_Start;
public InputAction @Pause => m_Wrapper.m_Meta_Pause;
public InputAction @Reset => m_Wrapper.m_Meta_Reset;
public InputActionMap Get() { return m_Wrapper.m_Meta; }
public void Enable() { Get().Enable(); }
public void Disable() { Get().Disable(); }
@ -706,6 +700,9 @@ public partial class @InputActionMaps: IInputActionCollection2, IDisposable
@Pause.started += instance.OnPause;
@Pause.performed += instance.OnPause;
@Pause.canceled += instance.OnPause;
@Reset.started += instance.OnReset;
@Reset.performed += instance.OnReset;
@Reset.canceled += instance.OnReset;
}
private void UnregisterCallbacks(IMetaActions instance)
@ -716,6 +713,9 @@ public partial class @InputActionMaps: IInputActionCollection2, IDisposable
@Pause.started -= instance.OnPause;
@Pause.performed -= instance.OnPause;
@Pause.canceled -= instance.OnPause;
@Reset.started -= instance.OnReset;
@Reset.performed -= instance.OnReset;
@Reset.canceled -= instance.OnReset;
}
public void RemoveCallbacks(IMetaActions instance)
@ -773,12 +773,12 @@ public partial class @InputActionMaps: IInputActionCollection2, IDisposable
{
void OnThrust(InputAction.CallbackContext context);
void OnSteer(InputAction.CallbackContext context);
void OnReset(InputAction.CallbackContext context);
void OnBoost(InputAction.CallbackContext context);
}
public interface IMetaActions
{
void OnStart(InputAction.CallbackContext context);
void OnPause(InputAction.CallbackContext context);
void OnReset(InputAction.CallbackContext context);
}
}

View File

@ -23,15 +23,6 @@
"interactions": "",
"initialStateCheck": true
},
{
"name": "Reset",
"type": "Button",
"id": "6ab0c9d5-b21f-4819-b5c8-ad277a1246c7",
"expectedControlType": "Button",
"processors": "",
"interactions": "",
"initialStateCheck": false
},
{
"name": "Boost",
"type": "PassThrough",
@ -340,28 +331,6 @@
"isComposite": false,
"isPartOfComposite": true
},
{
"name": "",
"id": "8c09092a-7323-4f5c-80df-19bfe90a207c",
"path": "<Keyboard>/r",
"interactions": "",
"processors": "",
"groups": "Keyboard 1;Keyboard 2",
"action": "Reset",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "b50ff906-5e23-4bd0-b5b7-98aeb46a2284",
"path": "<Gamepad>/select",
"interactions": "",
"processors": "",
"groups": "Controller",
"action": "Reset",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "f76aad49-c115-4d72-a860-b674c8489543",
@ -429,6 +398,15 @@
"processors": "",
"interactions": "",
"initialStateCheck": false
},
{
"name": "Reset",
"type": "Button",
"id": "476b1454-7144-4728-a5f3-3f98f839aeca",
"expectedControlType": "Button",
"processors": "",
"interactions": "",
"initialStateCheck": false
}
],
"bindings": [
@ -475,6 +453,28 @@
"action": "Pause",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "2e99e546-209d-410c-9d54-3482c05d8e90",
"path": "<Keyboard>/r",
"interactions": "",
"processors": "",
"groups": "Keyboard 1;Keyboard 2",
"action": "Reset",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "7e601b0a-6c05-4444-ac07-0e02fbf4b64b",
"path": "<Gamepad>/select",
"interactions": "",
"processors": "",
"groups": "Controller",
"action": "Reset",
"isComposite": false,
"isPartOfComposite": false
}
]
}

View File

@ -1,5 +1,4 @@
using System.Linq;
using JetBrains.Annotations;
using UnityEditor;
using UnityEditor.PackageManager;
using UnityEditor.SceneManagement;
@ -12,11 +11,11 @@ namespace PrimeTween {
[SerializeField] internal SceneAsset demoScene;
[SerializeField] internal SceneAsset demoSceneUrp;
[SerializeField] internal Color uninstallButtonColor;
[ContextMenu(nameof(ResetReviewRequest))]
void ResetReviewRequest() => ReviewRequest.ResetReviewRequest();
}
[CustomEditor(typeof(PrimeTweenInstaller), false)]
internal class InstallerInspector : Editor {
const string pluginName = "PrimeTween";
@ -26,7 +25,7 @@ namespace PrimeTween {
bool isInstalled;
GUIStyle boldButtonStyle;
GUIStyle uninstallButtonStyle;
void OnEnable() {
isInstalled = CheckPluginInstalled();
}
@ -60,7 +59,7 @@ namespace PrimeTween {
if (Button("Documentation", boldButtonStyle)) {
Application.OpenURL(documentationUrl);
}
Space(8);
if (Button("Open Demo", boldButtonStyle)) {
var rpAsset = GraphicsSettings.renderPipelineAsset;
@ -109,29 +108,36 @@ namespace PrimeTween {
Debug.LogError($"Please re-import the plugin from the Asset Store and check that the file exists: [{path}].\n\n{addRequest.Error?.message}\n");
}
}
#if !PRIME_TWEEN_INSTALLED && UNITY_2019_1_OR_NEWER
internal class AssetPostprocessor : UnityEditor.AssetPostprocessor {
static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths) {
foreach (var path in importedAssets) {
if (path == tgzPath) {
Selection.activeObject = AssetDatabase.LoadAssetAtPath<PrimeTweenInstaller>("Assets/Plugins/PrimeTween/PrimeTweenInstaller.asset");
installPlugin();
return;
[InitializeOnLoadMethod]
static void InitOnLoad() {
AssetDatabase.importPackageCompleted += name => {
if (name.Contains(pluginName)) {
if (ReviewRequest.PRIME_TWEEN_INSTALLED) {
ReviewRequest.TryAskForReview();
} else {
var installer = AssetDatabase.LoadAssetAtPath<PrimeTweenInstaller>("Assets/Plugins/PrimeTween/PrimeTweenInstaller.asset");
EditorUtility.FocusProjectWindow(); // this is important to show the installer object in the Project window
Selection.activeObject = installer;
EditorGUIUtility.PingObject(installer);
EditorApplication.update += InstallAndUnsubscribeFromUpdate;
void InstallAndUnsubscribeFromUpdate() {
EditorApplication.update -= InstallAndUnsubscribeFromUpdate;
installPlugin();
}
}
}
}
};
}
#endif
}
internal static class ReviewRequest {
const string version = "1.1.13";
const string version = "1.1.15";
const string canAskKey = "PrimeTween.canAskForReview";
const string versionKey = "PrimeTween.version";
[InitializeOnLoadMethod]
static void TryAskForReview() {
internal static void TryAskForReview() {
log("TryAskForReview");
if (!PRIME_TWEEN_INSTALLED) {
log("not installed");
return;
@ -157,11 +163,11 @@ namespace PrimeTween {
}
}
static bool PRIME_TWEEN_INSTALLED {
internal static bool PRIME_TWEEN_INSTALLED {
get {
#if PRIME_TWEEN_INSTALLED
return true;
#else
#else
return false;
#endif
}
@ -178,7 +184,7 @@ namespace PrimeTween {
get => EditorPrefs.GetString(versionKey);
set => EditorPrefs.SetString(versionKey, value);
}
static void DisableReviewRequest() => EditorPrefs.SetBool(canAskKey, false);
static void OpenReviewsURL() => Application.OpenURL("https://assetstore.unity.com/packages/slug/252960#reviews");
@ -202,9 +208,9 @@ namespace PrimeTween {
EditorPrefs.DeleteKey(canAskKey);
}
[PublicAPI]
[System.Diagnostics.Conditional("_")]
static void log(string msg) {
// Debug.Log($"ReviewRequest: {msg}");
Debug.Log($"ReviewRequest: {msg}");
}
}
}
}

8
Assets/Prefabs/UI.meta Normal file
View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 49d8d99050ef4024585d5b3372db0dae
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,379 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &3579044292502582008
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 106129460808279082}
- component: {fileID: 6106813766420979255}
- component: {fileID: 1625768591341040857}
- component: {fileID: 2836659166924155329}
m_Layer: 0
m_Name: Text
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &106129460808279082
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3579044292502582008}
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: 5031447595725426495}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: -0.000061035156, y: -4}
m_SizeDelta: {x: -31.9, y: -22.6}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &6106813766420979255
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3579044292502582008}
m_Enabled: 0
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e4870c7d0bdddd644a64ab8bc98f83ba, type: 3}
m_Name:
m_EditorClassIdentifier:
themeController: {fileID: 11400000, guid: e00c7d2bc58a2424b8dc09ecdafdb067, type: 2}
hasImage: 0
isText: 1
--- !u!222 &1625768591341040857
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3579044292502582008}
m_CullTransparentMesh: 1
--- !u!114 &2836659166924155329
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3579044292502582008}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, 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_text: Continue
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 3c4448e26b9824f499067d5cba19c732, type: 2}
m_sharedMaterial: {fileID: -7766214204018960760, guid: 3c4448e26b9824f499067d5cba19c732, type: 2}
m_fontSharedMaterials: []
m_fontMaterial: {fileID: 0}
m_fontMaterials: []
m_fontColor32:
serializedVersion: 2
rgba: 4294967295
m_fontColor: {r: 1, g: 1, b: 1, a: 1}
m_enableVertexGradient: 0
m_colorMode: 3
m_fontColorGradient:
topLeft: {r: 1, g: 1, b: 1, a: 1}
topRight: {r: 1, g: 1, b: 1, a: 1}
bottomLeft: {r: 1, g: 1, b: 1, a: 1}
bottomRight: {r: 1, g: 1, b: 1, a: 1}
m_fontColorGradientPreset: {fileID: 0}
m_spriteAsset: {fileID: 0}
m_tintAllSprites: 0
m_StyleSheet: {fileID: 0}
m_TextStyleHashCode: -1183493901
m_overrideHtmlColors: 0
m_faceColor:
serializedVersion: 2
rgba: 4294967295
m_fontSize: 18
m_fontSizeBase: 36
m_fontWeight: 400
m_enableAutoSizing: 1
m_fontSizeMin: 18
m_fontSizeMax: 72
m_fontStyle: 0
m_HorizontalAlignment: 1
m_VerticalAlignment: 512
m_textAlignment: 65535
m_characterSpacing: 0
m_wordSpacing: 0
m_lineSpacing: 0
m_lineSpacingMax: 0
m_paragraphSpacing: 0
m_charWidthMaxAdj: 0
m_enableWordWrapping: 1
m_wordWrappingRatios: 0.4
m_overflowMode: 0
m_linkedTextComponent: {fileID: 0}
parentLinkedComponent: {fileID: 0}
m_enableKerning: 1
m_enableExtraPadding: 0
checkPaddingRequired: 0
m_isRichText: 1
m_parseCtrlCharacters: 1
m_isOrthographic: 1
m_isCullingEnabled: 0
m_horizontalMapping: 0
m_verticalMapping: 0
m_uvLineOffset: 0
m_geometrySortingOrder: 0
m_IsTextObjectScaleStatic: 0
m_VertexBufferAutoSizeReduction: 0
m_useMaxVisibleDescender: 1
m_pageToDisplay: 1
m_margin: {x: 0, y: 0, z: 0, w: 0}
m_isUsingLegacyAnimationComponent: 0
m_isVolumetricText: 0
m_hasFontAssetChanged: 0
m_baseMaterial: {fileID: 0}
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
--- !u!1 &7542960674645323859
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 5031447595725426495}
- component: {fileID: 4524333150843825573}
- component: {fileID: 4776701562445095746}
- component: {fileID: 2370575273227441370}
- component: {fileID: 2510710616238763243}
- component: {fileID: 4688621401141212590}
m_Layer: 5
m_Name: Pause Menu Button
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &5031447595725426495
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7542960674645323859}
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:
- {fileID: 106129460808279082}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 77.3}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &4524333150843825573
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7542960674645323859}
m_CullTransparentMesh: 0
--- !u!114 &4776701562445095746
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7542960674645323859}
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: 0.53922683, 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_Sprite: {fileID: 21300000, guid: a8292d7c3170a7348accf3d85c0e7359, type: 3}
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 &2370575273227441370
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7542960674645323859}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Navigation:
m_Mode: -1
m_WrapAround: 0
m_SelectOnUp: {fileID: 0}
m_SelectOnDown: {fileID: 0}
m_SelectOnLeft: {fileID: 0}
m_SelectOnRight: {fileID: 0}
m_Transition: 2
m_Colors:
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
m_HighlightedColor: {r: 0.7169812, g: 0.7169812, b: 0.7169812, a: 1}
m_PressedColor: {r: 0.49056602, g: 0.49056602, b: 0.49056602, a: 1}
m_SelectedColor: {r: 0.7169812, g: 0.7169812, b: 0.7169812, a: 1}
m_DisabledColor: {r: 0.26415092, g: 0.26415092, b: 0.26415092, a: 0.11764706}
m_ColorMultiplier: 1
m_FadeDuration: 0.05
m_SpriteState:
m_HighlightedSprite: {fileID: 21300000, guid: a4fde6e0b21dc224d813ee493157874f, type: 3}
m_PressedSprite: {fileID: 21300000, guid: e5a390d359542f845bd18b3970c5eff3, type: 3}
m_SelectedSprite: {fileID: 21300000, guid: a4fde6e0b21dc224d813ee493157874f, type: 3}
m_DisabledSprite: {fileID: 0}
m_AnimationTriggers:
m_NormalTrigger: Normal
m_HighlightedTrigger: Highlighted
m_PressedTrigger: Pressed
m_SelectedTrigger: Highlighted
m_DisabledTrigger: Disabled
m_Interactable: 1
m_TargetGraphic: {fileID: 4776701562445095746}
m_OnClick:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 0}
m_TargetAssemblyTypeName:
m_MethodName: ReturnMenu
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!114 &2510710616238763243
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7542960674645323859}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e4870c7d0bdddd644a64ab8bc98f83ba, type: 3}
m_Name:
m_EditorClassIdentifier:
themeController: {fileID: 11400000, guid: e00c7d2bc58a2424b8dc09ecdafdb067, type: 2}
hasImage: 1
isText: 0
--- !u!114 &4688621401141212590
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7542960674645323859}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d0b148fe25e99eb48b9724523833bab1, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Delegates:
- eventID: 9
callback:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 0}
m_TargetAssemblyTypeName: UnityEngine.AudioSource, UnityEngine
m_MethodName: Play
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
- eventID: 15
callback:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 0}
m_TargetAssemblyTypeName: UnityEngine.AudioSource, UnityEngine
m_MethodName: Play
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
- eventID: 0
callback:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 0}
m_TargetAssemblyTypeName: UnityEngine.AudioSource, UnityEngine
m_MethodName: Play
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
- eventID: 4
callback:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 0}
m_TargetAssemblyTypeName: UnityEngine.AudioSource, UnityEngine
m_MethodName: Play
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

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: e269e0cd8b46eb94a8c118dc84754c33
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

4503
Assets/Scenes/InGameUI.unity Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: c8a237f579b0fab4c881d7ae29006574
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

30902
Assets/Scenes/MainMenu.unity Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: e294a6198c8b9d5428547c39abb8754b
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -13,18 +13,35 @@ public class GameplayMetaInputEvents : MonoBehaviour, IMetaActions
inputActions.Meta.SetCallbacks(this);
inputActions.Meta.Enable();
}
public void OnStart(InputAction.CallbackContext context)
{
MatchManager.G.StartPressed();
if (context.performed)
MatchManager.G.StartPressed();
}
public void OnPause(InputAction.CallbackContext context)
{
MatchManager.G.PausePressed();
if (context.performed)
MatchManager.G.PausePressed();
}
public void Dispose()
{
inputActions.Meta.Disable();
inputActions.Meta.RemoveCallbacks(this);
}
private void OnDestroy()
{
Dispose();
}
public void OnReset(InputAction.CallbackContext context)
{
#if DEBUG
MatchManager.G.ResetMatch();
#endif
return;
}
}

View File

@ -9,12 +9,16 @@ namespace ShipHandling
{
public class ShipInputHandler : IDisposable, IPlayerActions
{
private readonly ShipState state;
private ShipState state;
private readonly InputActionMaps inputActions = new();
private readonly string controlScheme;
private readonly InputDevice device;
public InputUser user;
public ShipInputHandler(ShipState shipState, InputDevice device, string controlScheme)
{
state = shipState;
this.controlScheme = controlScheme;
this.device = device;
user = InputUser.PerformPairingWithDevice(device);
user.AssociateActionsWithUser(inputActions);
user.ActivateControlScheme(controlScheme);
@ -22,6 +26,16 @@ namespace ShipHandling
inputActions.Player.Enable();
}
public void ReActivateInput(Ship ship)
{
// user = InputUser.PerformPairingWithDevice(device);
// user.AssociateActionsWithUser(inputActions);
// user.ActivateControlScheme(controlScheme);
this.state = ship.state;
inputActions.Player.SetCallbacks(this);
inputActions.Player.Enable();
}
public void OnThrust(InputAction.CallbackContext context)
{
state.thrustInput = context.ReadValue<float>();
@ -37,14 +51,6 @@ namespace ShipHandling
state.boostInput = context.ReadValue<float>();
}
public void OnReset(InputAction.CallbackContext context)
{
if (Debug.isDebugBuild)
{
state.reset = true;
}
}
public void Dispose()
{
inputActions.Player.Disable();

View File

@ -88,6 +88,11 @@ public class ManageableAudio : MonoBehaviour
}
}
public void DestroyAudio()
{
Destroy(gameObject);
}
/// <summary>
/// Updates the pitch of the audio clip.
/// </summary>
@ -104,7 +109,12 @@ public class ManageableAudio : MonoBehaviour
AudioSource.volume = initialVolume + (changeValue * volumeRange);
}
public void FadeOutAudio(float duration = 1)
/// <summary>
/// Fades the volume of the audio source to 0 in the given interval.
/// </summary>
/// <param name="duration">Time for fade out</param>
/// <param name="destroyedAfter">Destroy the object after fade out?</param>
public void FadeOutAudio(float duration = 1, bool destroyedAfter = false)
{
if (IsUpdating)
{
@ -129,6 +139,7 @@ public class ManageableAudio : MonoBehaviour
IsUpdating = false;
StopAudio();
AudioSource.volume = initVolume;
if (destroyedAfter) Destroy(gameObject);
});
}

View File

@ -56,7 +56,7 @@ namespace Managers
/// <returns>ManageableAudio instance to control the playback with.</returns>
public ManageableAudio GetGlobalSoundByName(string prefabName, bool dependsOnScene = false)
{
return GetGlobalSound(null, -1, false, SearchSound(null, -1, prefabName));
return GetGlobalSound(null, -1, dependsOnScene, SearchSound(null, -1, prefabName));
}
/// <summary>
@ -74,7 +74,8 @@ namespace Managers
/// <summary>
/// Instantiates a sound from the library which will be used for global sound.
/// TODO: Only makes sense, if requested prefab has 0 spatial value.
/// The ManageableAudio object is instantiated in the currently active scene,
/// when dependsOnScene is true!
/// </summary>
/// <param name="audioTag">Tag of the sound</param>
/// <param name="id">ID of the sound</param>
@ -159,8 +160,6 @@ namespace Managers
// -"- scene dependent and global -> will play globally but when the scene is destroyed they will be also destroyed
// -"- scene dependent and local -> will play spatially from a object and be destroyed when the scene is destroyed
//
Dictionary<ManageableAudio, GameObject> ReadLibrary(AudioLibrary al)
{
Dictionary<ManageableAudio, GameObject> audioDictionary =

View File

@ -37,6 +37,16 @@ namespace Managers
if (p.character.shipInput != null)
{
ShipInputHandler input = p.character.shipInput;
if (p.spawnedCharacter.TryGetComponent(out Ship ship))
{
input.ReActivateInput(ship);
}
else
{
Log.Error($"Character for player {p.name} contained no ship." +
" \n Can't reattach controls.");
continue;
}
// TODO: Make this more unique with the GUID and save across more
// and different scenarios?
playersControlSchemes.Add(p.playerNumber,

View File

@ -15,8 +15,8 @@ using UnityEngine.SceneManagement;
public enum Scenes
{
GameMangement,
MenuUserInterface,
GameplayUserInterface,
MainMenu,
InGameUI,
Arena,
}
@ -175,8 +175,8 @@ namespace Managers
{
SceneManager.SetActiveScene(args.SceneRef);
startCamera.SetActive(false);
}, Scenes.MenuUserInterface);
SceneManager.LoadSceneAsync((int)Scenes.MenuUserInterface, LoadSceneMode.Additive);
}, Scenes.MainMenu);
SceneManager.LoadSceneAsync((int)Scenes.MainMenu, LoadSceneMode.Additive);
Log.Info("Main menu scene loaded.");
}
@ -215,19 +215,23 @@ namespace Managers
MatchManager.StartMatch();
}
/// <summary>
/// Starts a match scene without the menus or input/start prompts.
/// </summary>
/// <param name="scene">The match scene which will be loaded</param>
/// <returns></returns>
public IEnumerator SetupTestMatch(Scenes scene)
{
yield return null;
SceneManager.LoadScene((int)scene, LoadSceneMode.Additive);
yield return null;
SceneManager.LoadScene((int)Scenes.GameplayUserInterface, LoadSceneMode.Additive);
SceneManager.LoadScene((int)Scenes.InGameUI, LoadSceneMode.Additive);
yield return null;
SceneManager.SetActiveScene(SceneManager.GetSceneByBuildIndex((int)scene));
yield return null;
MatchManager.LoadMatchRules(0);
MatchManager.LoadArenaProperties(0);
PlayerManager.LocalMatchJoinPlayers(MatchManager.arenaProperties.minPlayerCount);
// TODO: This is in place of a character choosing menu etc.
foreach (Player p in PlayerManager.localPlayers)
{
CharacterManager.AssignShipFixed(p);
@ -281,7 +285,6 @@ namespace Managers
SceneManager.sceneLoaded += OnSceneLoaded;
}
}
/// <summary>

View File

@ -57,6 +57,9 @@ namespace Managers
private static string arenaAssetsPath = "Assets/ScriptedAssets/Arenas";
private static string ruleAssetsPath = "Assets/ScriptedAssets/Rules";
public GameObject MatchArena;
public GameObject MatchCamera;
public event Action OnStartPressed;
/// <summary>
/// Globally accessible member to use manager with.
@ -179,7 +182,10 @@ namespace Managers
Score = matchRule.score,
Time = matchRule.time
};
matchPlayerStatistics.Add(p, mps);
if (!matchPlayerStatistics.TryAdd(p, mps))
{
Log.Info($"Player {p.name} already has statistics set up.");
}
}
}
@ -310,15 +316,22 @@ namespace Managers
/// </summary>
public void StartPressed()
{
OnStartPressed?.Invoke();
if (matchState != MatchState.Match)
{
OnStartPressed?.Invoke();
return;
}
}
public void PausePressed()
{
// TODO: MetaInputEvent in InGameUI scene -> PausePressed here -> ShowPauseMenu in UIManager -> PauseMenu Show
// When clicking continue in PauseMenu -> PausePressed here -> UIManager HidePause -> PauseMenu Hide
if (matchState == MatchState.Pause)
{
ContinueMatch();
UIManager.G.ShowPauseMenu();
UIManager.G.HidePauseMenu();
MatchCamera.SetActive(true);
return;
}
if (matchState != MatchState.Match)
@ -327,12 +340,12 @@ namespace Managers
return;
}
matchState = MatchState.Pause;
UIManager.G.HidePauseMenu();
UIManager.G.ShowPauseMenu(MatchArena.transform);
MatchCamera.SetActive(false);
}
async private void ContinueMatch()
{
UIManager.G.announcments.QueueAnnounceText("Get Ready.", 0.3f);
UIManager.G.announcments.QueueAnnounceText("Get Ready..", 0.3f);
UIManager.G.announcments.QueueAnnounceText("Get Ready...", 0.3f);
@ -349,14 +362,14 @@ namespace Managers
public void SpawnCharacters(List<Player> players)
{
// TODO: This belongs in another intialization method
GameObject arena = GameObject.Find("Arena Placement");
GameObject matchCamera = GameObject.Find("Match Camera");
if (arena == null)
MatchArena = GameObject.Find("Arena Placement");
MatchCamera = GameObject.Find("Match Camera");
if (MatchArena == null)
{
Log.Error("ArenaPlacement not found in scenes. Cannot spawn players.");
return;
}
if (matchCamera == null)
if (MatchCamera == null)
{
Log.Error("Match camera not found in scenes. Cannot initialize spawned Characters.");
return;
@ -368,8 +381,8 @@ namespace Managers
p.spawnedCharacter = shipObject;
shipObject.TryGetComponent(out Ship ship);
ship.state = new ShipHandling.ShipState();
ship.cameraOperator = matchCamera.GetComponent<CameraOperator>();
shipObject.transform.SetParent(arena.transform, false);
ship.cameraOperator = MatchCamera.GetComponent<CameraOperator>();
shipObject.transform.SetParent(MatchArena.transform, false);
shipObject.transform.localPosition =
arenaProperties.spawnPositions[p.playerNumber - 1];

View File

@ -111,14 +111,19 @@ namespace Managers
announcments.StopAnnouncement();
}
public void ShowPauseMenu()
public void ShowPauseMenu(Transform transform)
{
pauseMenu?.Show(transform);
}
public void HidePauseMenu()
{
pauseMenu?.Hide();
}
public void HideHUD()
{
hUD?.Hide();
}
}
}

View File

@ -99,7 +99,8 @@ public class NimbleZoneDetection : MonoBehaviour
private void OnTriggerEnter(Collider collider)
{
int instanceID = collider.gameObject.GetInstanceID();
if (collider.tag == "Spike" && MatchManager.G.matchState == MatchState.Match)
if (collider.tag == "Spike"
&& collider.attachedRigidbody.velocity.magnitude > 1)
{
SpawnRipple(collider, false);
return;
@ -114,7 +115,7 @@ public class NimbleZoneDetection : MonoBehaviour
private void OnTriggerExit(Collider collider)
{
int instanceID = collider.gameObject.GetInstanceID();
if (collider.tag == "Spike" && MatchManager.G.matchState == MatchState.Match)
if (collider.tag == "Spike")
{
SpawnRipple(collider, true);
return;

View File

@ -6,6 +6,7 @@ using Managers;
using GameLogic;
using Unity.VisualScripting;
using Unity.Mathematics;
using System.Text.RegularExpressions;
public class Ship : MonoBehaviour
{
@ -82,27 +83,17 @@ public class Ship : MonoBehaviour
// Update is called once per frame
void FixedUpdate()
{
// TODO: This is handled by match manager now
if (state.reset)
{
state.reset = false;
body.velocity = Vector3.zero;
body.transform.rotation = body.transform.parent.rotation;
MatchManager.G.StartMatch();
}
// TODO: This belongs in the state object
newZone = forceManager.GetZoneOfInstance(InstanceID);
// TODO: This could be more elegant maybe?
if (MatchManager.G.matchState != MatchState.Match)
{
body.constraints = RigidbodyConstraints.FreezeAll;
UpdateSounds();
zone = newZone;
return;
}
body.constraints = RigidbodyConstraints.None;
// TODO: This belongs in the state object
newZone = forceManager.GetZoneOfInstance(InstanceID);
//BoostStateUpdate(Time.deltaTime);
// Rotate the vehicle with the current steer velocity
// Calculate the magnitude of the acceleration with the current thrust
UpdateSounds();
if (zone != newZone)
{
@ -339,9 +330,6 @@ public class Ship : MonoBehaviour
Vector3 colliderVelocity = collider.attachedRigidbody.velocity;
Vector3 tackleDirection = transform.position - collider.transform.position;
// tackleDirection = Vector3.ProjectOnPlane(tackleDirection,
// Vector3.Cross(transform.up, transform.right));
body.AddForce(colliderVelocity.magnitude * tackleDirection * tacklePowerFactor,
ForceMode.Acceleration);
UpdateTackleResponse(true);
@ -349,6 +337,17 @@ public class Ship : MonoBehaviour
void UpdateSounds()
{
if (MatchManager.G.matchState != MatchState.Match)
{
if (newZone != zone
&& newZone == Zone.NimbleZone)
{
AudioManager.G.BroadcastAudioEffect(AudioEffects.LowPass, transform, false);
}
ThrusterSound.StopAudio();
return;
}
float velocityFactor = math.smoothstep(0, props.absolutMaxVelocity, body.velocity.magnitude);
if (math.abs(state.thrustInput) > 0 || IsBoosting())
{
@ -381,7 +380,9 @@ public class Ship : MonoBehaviour
BeingCriticallyTackledSound.ResetOneShot();
BeingTackledSound.ResetOneShot();
}
if (newZone != zone)
if (newZone != zone
&& zone != Zone.UninitializedZone
&& newZone != Zone.UninitializedZone)
{
if (newZone != Zone.NimbleZone)
{

View File

@ -26,7 +26,7 @@ public class BoostCapacityUI : MonoBehaviour
public void SetPlayerName(Player p)
{
hint.SetText($"Boost Capacity \n {p.playerName} \n {p.character.shipName}");
hint.SetText($"{p.character.shipName} \n {p.playerName}");
}
/// <summary>

View File

@ -8,6 +8,13 @@ public class HUD : MonoBehaviour
public BoostCapacityUI[] boostCapacities;
public JoinPrompt[] joinPrompts;
private Canvas canvas;
void Awake()
{
canvas = gameObject.GetComponent<Canvas>();
}
/// <summary>
/// Start a join prompt.
/// </summary>
@ -23,4 +30,10 @@ public class HUD : MonoBehaviour
}
}
}
public void Hide()
{
canvas.enabled = false;
}
}

View File

@ -1,19 +1,99 @@
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using log4net;
using Managers;
using SlimUI.ModernMenu;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.SceneManagement;
public class PauseMenu : MonoBehaviour
{
private static ILog Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private Canvas Canvas;
public GameObject Camera;
public GameObject UIEventSystem;
public GameObject PauseMenuButtons;
public GameObject ExitConfirmDialog;
public GameObject FocusButtonExitConfirm;
public GameObject FocusButtonPause;
private EventSystem eventSystem;
// Start is called before the first frame update
void Start()
{
}
void Awake()
{
Canvas = gameObject.GetComponent<Canvas>();
Canvas.enabled = false;
eventSystem = UIEventSystem.GetComponent<EventSystem>();
}
public void Show(Transform transform)
{
gameObject.transform.position = transform.position;
gameObject.transform.rotation = transform.rotation;
Canvas.enabled = true;
Camera.SetActive(true);
UIEventSystem.SetActive(true);
PauseMenuButtons.SetActive(true);
ExitConfirmDialog.SetActive(false);
eventSystem.SetSelectedGameObject(FocusButtonPause, null);
}
public void Hide()
{
Canvas.enabled = false;
Camera.SetActive(false);
UIEventSystem.SetActive(false);
}
public void OnContinue()
{
MatchManager.G.PausePressed();
}
public void OnMainMenu()
{
StartCoroutine(StartSceneTransition());
}
private IEnumerator StartSceneTransition()
{
Canvas.enabled = false;
SceneManager.LoadScene((int)Scenes.MainMenu, LoadSceneMode.Additive);
yield return new WaitForSeconds(0.2f);
GameObject menu = GameObject.Find("Main Menu Camera");
if (menu != null && menu.TryGetComponent(out SlimUIMainMenu menuScript))
{
UIManager.G.HideHUD();
menuScript.MenuTransition(Camera.GetComponent<Camera>().transform);
}
else
{
Log.Error("Can't transition back to main menu. Menu camera or script not found.");
}
}
public void OnExit()
{
PauseMenuButtons.SetActive(false);
ExitConfirmDialog.SetActive(true);
eventSystem.SetSelectedGameObject(FocusButtonExitConfirm, null);
}
public void OnConfirmedExit()
{
#if UNITY_EDITOR
UnityEditor.EditorApplication.isPlaying = false;
#else
Application.Quit();
#endif
}
public void OnBackToPauseMenu()
{
PauseMenuButtons.SetActive(true);
ExitConfirmDialog.SetActive(false);
eventSystem.SetSelectedGameObject(FocusButtonPause, null);
}
// Update is called once per frame
void Update()
{
}
}

View File

@ -9,9 +9,9 @@ GameObject:
serializedVersion: 6
m_Component:
- component: {fileID: 5206892685566439831}
- component: {fileID: 5407840496720808303}
- component: {fileID: 5389521700824258581}
- component: {fileID: 5429289958580070962}
- component: {fileID: 6494235282669128620}
- component: {fileID: 3132460205455581372}
m_Layer: 0
m_Name: Text
m_TagString: Untagged
@ -38,49 +38,30 @@ RectTransform:
m_AnchoredPosition: {x: -0.000061035156, y: -4}
m_SizeDelta: {x: -31.9, y: -22.6}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!23 &5407840496720808303
MeshRenderer:
--- !u!114 &5429289958580070962
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5429289958580070961}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RayTraceProcedural: 0
m_RenderingLayerMask: 4294967295
m_RendererPriority: 0
m_Materials:
- {fileID: -7766214204018960760, guid: 3c4448e26b9824f499067d5cba19c732, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 0
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}
--- !u!114 &5389521700824258581
m_Enabled: 0
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e4870c7d0bdddd644a64ab8bc98f83ba, type: 3}
m_Name:
m_EditorClassIdentifier:
themeController: {fileID: 11400000, guid: e00c7d2bc58a2424b8dc09ecdafdb067, type: 2}
hasImage: 0
isText: 1
--- !u!222 &6494235282669128620
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5429289958580070961}
m_CullTransparentMesh: 1
--- !u!114 &3132460205455581372
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
@ -89,7 +70,7 @@ MonoBehaviour:
m_GameObject: {fileID: 5429289958580070961}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 9541d86e2fd84c1d9990edf0852d74ab, type: 3}
m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
@ -100,7 +81,7 @@ MonoBehaviour:
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_text: Play
m_text:
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 3c4448e26b9824f499067d5cba19c732, type: 2}
m_sharedMaterial: {fileID: -7766214204018960760, guid: 3c4448e26b9824f499067d5cba19c732, type: 2}
@ -127,15 +108,15 @@ MonoBehaviour:
m_faceColor:
serializedVersion: 2
rgba: 4294967295
m_fontSize: 400
m_fontSizeBase: 400
m_fontSize: 36
m_fontSizeBase: 36
m_fontWeight: 400
m_enableAutoSizing: 0
m_enableAutoSizing: 1
m_fontSizeMin: 18
m_fontSizeMax: 72
m_fontStyle: 0
m_HorizontalAlignment: 1
m_VerticalAlignment: 4096
m_VerticalAlignment: 256
m_textAlignment: 65535
m_characterSpacing: 0
m_wordSpacing: 0
@ -153,40 +134,22 @@ MonoBehaviour:
checkPaddingRequired: 0
m_isRichText: 1
m_parseCtrlCharacters: 1
m_isOrthographic: 0
m_isOrthographic: 1
m_isCullingEnabled: 0
m_horizontalMapping: 0
m_verticalMapping: 0
m_uvLineOffset: 0
m_geometrySortingOrder: 0
m_IsTextObjectScaleStatic: 0
m_VertexBufferAutoSizeReduction: 1
m_VertexBufferAutoSizeReduction: 0
m_useMaxVisibleDescender: 1
m_pageToDisplay: 1
m_margin: {x: 0, y: 0, z: 0, w: 0}
m_isUsingLegacyAnimationComponent: 0
m_isVolumetricText: 0
_SortingLayer: 0
_SortingLayerID: 0
_SortingOrder: 0
m_hasFontAssetChanged: 0
m_renderer: {fileID: 5407840496720808303}
m_maskType: 0
--- !u!114 &5429289958580070962
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5429289958580070961}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e4870c7d0bdddd644a64ab8bc98f83ba, type: 3}
m_Name:
m_EditorClassIdentifier:
themeController: {fileID: 11400000, guid: e00c7d2bc58a2424b8dc09ecdafdb067, type: 2}
hasImage: 0
isText: 1
m_baseMaterial: {fileID: 0}
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
--- !u!1 &5429341922959870843
GameObject:
m_ObjectHideFlags: 0

View File

@ -90,6 +90,11 @@ namespace SlimUI.ModernMenu
[Tooltip("The GameObject holding the Audio Source component for the SWOOSH SOUND when switching to the Settings Screen")]
public AudioSource swooshSound;
void Awake()
{
SceneManager.activeSceneChanged += CameraOnSceneActive;
}
void Start()
{
GM = GameManager.G;
@ -100,10 +105,11 @@ namespace SlimUI.ModernMenu
firstMenu.SetActive(true);
// Position1();
SetThemeColors();
MainMenuMusic = AudioManager.G.GetGlobalSound("main_menu_music", 1, true);
MainMenuMusic = AudioManager.G.GetGlobalSound("main_menu_music", 1, false);
MainMenuMusic.PlayAudio(true);
}
void SetThemeColors()
{
switch (theme)
@ -160,14 +166,13 @@ namespace SlimUI.ModernMenu
/// <param name="sceneId">The scene id which will be loaded (see Scenes enum)</param>
public void LoadScene(int sceneId)
{
if (GameManager.G != null)
if (GM != null)
{
if (((Scenes)sceneId).ToString() == "Arena")
{
GM.SingleUseSceneLoadedMethodCaller(ArenaTransition, Scenes.Arena);
}
}
optionsCanvas.SetActive(false);
StartCoroutine(LoadAsynchronously((Scenes)sceneId));
}
@ -191,6 +196,7 @@ namespace SlimUI.ModernMenu
gameObject.TryGetComponent(out Camera oldCamera);
gameObject.TryGetComponent(out AudioListener oldListener);
gameObject.GetComponent<Animator>().enabled = false;
optionsCanvas.SetActive(false);
// Camera flight tween with camera hand-off at the end.
Sequence.Create()
.Group(Tween.Position(gameObject.transform, target.transform.position, 2f))
@ -210,6 +216,36 @@ namespace SlimUI.ModernMenu
}
}
/// <summary>
/// Defines a delegate which animates a camera flight and
/// gives it to the game manager to execute once the scene is loaded.
/// </summary>
/// <param name="sceneEnum">The scene which when loaded triggers the event +
/// delegate execution</param>
public void MenuTransition(Transform cameraTransform)
{
Log.Info("Camera will fly to the main menu scene");
optionsCanvas.SetActive(false);
if (gameObject.TryGetComponent(out Camera target))
{
// Camera flight tween with camera hand-off at the end.
Sequence.Create()
.Group(Tween.Position(cameraTransform, target.transform.position, 2f))
.Group(Tween.Rotation(cameraTransform, target.transform.rotation, 2f))
.ChainCallback(() =>
{
SceneManager.SetActiveScene(SceneManager.GetSceneByBuildIndex((int)Scenes.MainMenu));
optionsCanvas.SetActive(true);
SceneManager.UnloadSceneAsync((int)Scenes.InGameUI);
SceneManager.UnloadSceneAsync((int)Scenes.Arena);
});
}
else
{
Log.Error("Menu has no camera component.");
}
}
/// <summary>
/// Loads the Gameplay UI and after that unloads the Main Menu.
/// Also Initiates the setup of the local match once the Gameplay UI is
@ -218,8 +254,8 @@ namespace SlimUI.ModernMenu
/// <returns>IEnumerator for async statemachine</returns>
private IEnumerator SwitchToIngameUI()
{
MainMenuMusic.FadeOutAudio(2);
AsyncOperation o = SceneManager.LoadSceneAsync((int)Scenes.GameplayUserInterface,
MainMenuMusic.FadeOutAudio(2, true);
AsyncOperation o = SceneManager.LoadSceneAsync((int)Scenes.InGameUI,
LoadSceneMode.Additive);
while (!o.isDone)
@ -228,7 +264,7 @@ namespace SlimUI.ModernMenu
}
yield return new WaitForSeconds(0.1f);
yield return StartCoroutine(GM.SetupLocalMatchFromMainMenu());
SceneManager.UnloadSceneAsync((int)Scenes.MenuUserInterface);
SceneManager.UnloadSceneAsync((int)Scenes.MainMenu);
}
public void DisablePlayCampaign()
@ -389,5 +425,31 @@ namespace SlimUI.ModernMenu
}
while (!operation.isDone);
}
/// <summary>
/// Enable the menu camera, when the main menu scene is set as active.
/// </summary>
/// <param name="oldScene">Scene which was active before</param>
/// <param name="newScene">Newly active scene</param>
private void CameraOnSceneActive(Scene oldScene, Scene newScene)
{
if (newScene == SceneManager.GetSceneByBuildIndex((int)Scenes.MainMenu))
{
if (gameObject.TryGetComponent(out Camera camera))
{
camera.enabled = true;
}
if (gameObject.TryGetComponent(out AudioListener listener))
{
listener.enabled = true;
}
}
}
private void OnDestroy()
{
SceneManager.activeSceneChanged -= CameraOnSceneActive;
}
}
}

View File

@ -24,7 +24,7 @@ namespace SlimUI.ModernMenu{
message = gameObject;
if(isText){
message.GetComponent<TextMeshPro>().color = themeController.textColor;
message.GetComponent<TextMeshProUGUI>().color = themeController.textColor;
}
}
}

View File

@ -9,10 +9,10 @@ EditorBuildSettings:
path: Assets/Scenes/GameManagement.unity
guid: 84d1a613c576379438533bb2a666fc97
- enabled: 1
path: Assets/Scenes/MenuUserInterface.unity
path: Assets/Scenes/MainMenu.unity
guid: e294a6198c8b9d5428547c39abb8754b
- enabled: 1
path: Assets/Scenes/GamePlayUserInterface.unity
path: Assets/Scenes/InGameUI.unity
guid: c8a237f579b0fab4c881d7ae29006574
- enabled: 1
path: Assets/Scenes/Arena.unity