added main game state and mainmenu state
This commit is contained in:
parent
5091983da6
commit
c0fd94cd30
10
.idea/.idea.SpringJam2026/.idea/workspace.xml
generated
10
.idea/.idea.SpringJam2026/.idea/workspace.xml
generated
@ -7,10 +7,8 @@
|
|||||||
<list default="true" id="60468364-7d9c-427f-83f9-f6cd83ef8783" name="Changes" comment="">
|
<list default="true" id="60468364-7d9c-427f-83f9-f6cd83ef8783" name="Changes" comment="">
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/.idea.SpringJam2026/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.SpringJam2026/.idea/workspace.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/.idea.SpringJam2026/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.SpringJam2026/.idea/workspace.xml" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/Assets/Scenes/Bootstrap.unity" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Scenes/Bootstrap.unity" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/Assets/Scenes/Bootstrap.unity" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Scenes/Bootstrap.unity" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/Assets/Scripts/Management/BGM.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Scripts/Management/BGM.cs" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/Assets/Scenes/MainMenu.unity" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Scenes/MainMenu.unity" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/Assets/Scripts/Management/SFX.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Scripts/Management/SFX.cs" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/Assets/Scripts/State/Game/MainMenuState.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Scripts/State/Game/MainMenuState.cs" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/Assets/Scripts/Management/Services.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Scripts/Management/Services.cs" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/ProjectSettings/EditorBuildSettings.asset" beforeDir="false" afterPath="$PROJECT_DIR$/ProjectSettings/EditorBuildSettings.asset" afterDir="false" />
|
|
||||||
</list>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
@ -21,7 +19,9 @@
|
|||||||
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
||||||
</component>
|
</component>
|
||||||
<component name="HighlightingSettingsPerFile">
|
<component name="HighlightingSettingsPerFile">
|
||||||
|
<setting file="file://$PROJECT_DIR$/Assets/Scripts/State/Game/MainGameState.cs" root0="FORCE_HIGHLIGHTING" />
|
||||||
<setting file="file://$PROJECT_DIR$/Assets/Scripts/State/Game/MainMenuState.cs" root0="FORCE_HIGHLIGHTING" />
|
<setting file="file://$PROJECT_DIR$/Assets/Scripts/State/Game/MainMenuState.cs" root0="FORCE_HIGHLIGHTING" />
|
||||||
|
<setting file="file://$PROJECT_DIR$/Assets/Scripts/State/Game/MainStateMachine.cs" root0="FORCE_HIGHLIGHTING" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectColorInfo"><![CDATA[{
|
<component name="ProjectColorInfo"><![CDATA[{
|
||||||
"associatedIndex": 6
|
"associatedIndex": 6
|
||||||
@ -114,7 +114,7 @@
|
|||||||
<option name="number" value="Default" />
|
<option name="number" value="Default" />
|
||||||
<option name="presentableId" value="Default" />
|
<option name="presentableId" value="Default" />
|
||||||
<updated>1777050991106</updated>
|
<updated>1777050991106</updated>
|
||||||
<workItem from="1777050993247" duration="4028000" />
|
<workItem from="1777050993247" duration="5854000" />
|
||||||
</task>
|
</task>
|
||||||
<servers />
|
<servers />
|
||||||
</component>
|
</component>
|
||||||
|
|||||||
8
Assets/Prefabs.meta
Normal file
8
Assets/Prefabs.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: ad6f5bb99bf5483428907989a6f4523b
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
8
Assets/Prefabs/UI.meta
Normal file
8
Assets/Prefabs/UI.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: c424f0b586251414baa6d6a6504c51d8
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
70
Assets/Prefabs/UI/MainMenu.prefab
Normal file
70
Assets/Prefabs/UI/MainMenu.prefab
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!1 &1522947426740712753
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 4714161115413790785}
|
||||||
|
- component: {fileID: 5464361591880727452}
|
||||||
|
- component: {fileID: 4116044285910179794}
|
||||||
|
m_Layer: 5
|
||||||
|
m_Name: MainMenu
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!4 &4714161115413790785
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1522947426740712753}
|
||||||
|
serializedVersion: 2
|
||||||
|
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: 0}
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!114 &5464361591880727452
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1522947426740712753}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 19102, guid: 0000000000000000e000000000000000, type: 0}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier: UnityEngine.dll::UnityEngine.UIElements.UIDocument
|
||||||
|
m_PanelSettings: {fileID: 11400000, guid: 4f01bbaf43abd294b9e7341d0530a9aa, type: 2}
|
||||||
|
m_ParentUI: {fileID: 0}
|
||||||
|
sourceAsset: {fileID: 9197481963319205126, guid: d29bfcc0217a10b488edd76a7ae59cf2, type: 3}
|
||||||
|
m_SortingOrder: 0
|
||||||
|
m_Position: 0
|
||||||
|
m_WorldSpaceSizeMode: 1
|
||||||
|
m_WorldSpaceWidth: 1920
|
||||||
|
m_WorldSpaceHeight: 1080
|
||||||
|
m_PivotReferenceSize: 0
|
||||||
|
m_Pivot: 0
|
||||||
|
m_WorldSpaceCollider: {fileID: 0}
|
||||||
|
--- !u!114 &4116044285910179794
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1522947426740712753}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 313c38e8548656447b712e4191d6e57c, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier: Assembly-CSharp::UI.MainMenu
|
||||||
7
Assets/Prefabs/UI/MainMenu.prefab.meta
Normal file
7
Assets/Prefabs/UI/MainMenu.prefab.meta
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 0453e357da6c33c468bb3d3726552b8e
|
||||||
|
PrefabImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -262,6 +262,51 @@ AudioSource:
|
|||||||
m_PreInfinity: 2
|
m_PreInfinity: 2
|
||||||
m_PostInfinity: 2
|
m_PostInfinity: 2
|
||||||
m_RotationOrder: 4
|
m_RotationOrder: 4
|
||||||
|
--- !u!1 &1469922749
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 1469922751}
|
||||||
|
- component: {fileID: 1469922750}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: GameStateMachine
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!114 &1469922750
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1469922749}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 8ceca53f0e424e51a6c75d7a4bd1074d, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier: Assembly-CSharp::State.Game.MainStateMachine
|
||||||
|
mainMenuPrefab: {fileID: 1522947426740712753, guid: 0453e357da6c33c468bb3d3726552b8e, type: 3}
|
||||||
|
--- !u!4 &1469922751
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1469922749}
|
||||||
|
serializedVersion: 2
|
||||||
|
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: 0}
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
--- !u!1 &1671688483
|
--- !u!1 &1671688483
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -322,6 +367,7 @@ MonoBehaviour:
|
|||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier: Assembly-CSharp::Bootstrap
|
m_EditorClassIdentifier: Assembly-CSharp::Bootstrap
|
||||||
startType: 1
|
startType: 1
|
||||||
|
gameStateMachine: {fileID: 1469922750}
|
||||||
--- !u!1 &1755353616
|
--- !u!1 &1755353616
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -471,3 +517,4 @@ SceneRoots:
|
|||||||
- {fileID: 1671688485}
|
- {fileID: 1671688485}
|
||||||
- {fileID: 1755353619}
|
- {fileID: 1755353619}
|
||||||
- {fileID: 1327356648}
|
- {fileID: 1327356648}
|
||||||
|
- {fileID: 1469922751}
|
||||||
|
|||||||
@ -256,64 +256,8 @@ MonoBehaviour:
|
|||||||
m_VarianceClampScale: 0.9
|
m_VarianceClampScale: 0.9
|
||||||
m_ContrastAdaptiveSharpening: 0
|
m_ContrastAdaptiveSharpening: 0
|
||||||
m_Version: 2
|
m_Version: 2
|
||||||
--- !u!1 &1819373722
|
|
||||||
GameObject:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
serializedVersion: 6
|
|
||||||
m_Component:
|
|
||||||
- component: {fileID: 1819373724}
|
|
||||||
- component: {fileID: 1819373723}
|
|
||||||
m_Layer: 5
|
|
||||||
m_Name: MainMenu
|
|
||||||
m_TagString: Untagged
|
|
||||||
m_Icon: {fileID: 0}
|
|
||||||
m_NavMeshLayer: 0
|
|
||||||
m_StaticEditorFlags: 0
|
|
||||||
m_IsActive: 1
|
|
||||||
--- !u!114 &1819373723
|
|
||||||
MonoBehaviour:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 1819373722}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_EditorHideFlags: 0
|
|
||||||
m_Script: {fileID: 19102, guid: 0000000000000000e000000000000000, type: 0}
|
|
||||||
m_Name:
|
|
||||||
m_EditorClassIdentifier: UnityEngine.dll::UnityEngine.UIElements.UIDocument
|
|
||||||
m_PanelSettings: {fileID: 11400000, guid: 4f01bbaf43abd294b9e7341d0530a9aa, type: 2}
|
|
||||||
m_ParentUI: {fileID: 0}
|
|
||||||
sourceAsset: {fileID: 9197481963319205126, guid: d29bfcc0217a10b488edd76a7ae59cf2, type: 3}
|
|
||||||
m_SortingOrder: 0
|
|
||||||
m_Position: 0
|
|
||||||
m_WorldSpaceSizeMode: 1
|
|
||||||
m_WorldSpaceWidth: 1920
|
|
||||||
m_WorldSpaceHeight: 1080
|
|
||||||
m_PivotReferenceSize: 0
|
|
||||||
m_Pivot: 0
|
|
||||||
m_WorldSpaceCollider: {fileID: 0}
|
|
||||||
--- !u!4 &1819373724
|
|
||||||
Transform:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 1819373722}
|
|
||||||
serializedVersion: 2
|
|
||||||
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: 0}
|
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
|
||||||
--- !u!1660057539 &9223372036854775807
|
--- !u!1660057539 &9223372036854775807
|
||||||
SceneRoots:
|
SceneRoots:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
m_Roots:
|
m_Roots:
|
||||||
- {fileID: 478016690}
|
- {fileID: 478016690}
|
||||||
- {fileID: 1819373724}
|
|
||||||
|
|||||||
7
Assets/Scripts/State/Game/MainGameState.cs
Normal file
7
Assets/Scripts/State/Game/MainGameState.cs
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
namespace State.Game
|
||||||
|
{
|
||||||
|
public class MainGameState : GameState
|
||||||
|
{
|
||||||
|
protected MainStateMachine MainStateMachine => (MainStateMachine)StateMachine;
|
||||||
|
}
|
||||||
|
}
|
||||||
3
Assets/Scripts/State/Game/MainGameState.cs.meta
Normal file
3
Assets/Scripts/State/Game/MainGameState.cs.meta
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 03265909fca144b289ccf928c08acd42
|
||||||
|
timeCreated: 1777056025
|
||||||
@ -1,14 +1,55 @@
|
|||||||
using UnityEngine.SceneManagement;
|
using System.Collections;
|
||||||
|
using UI;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.SceneManagement;
|
||||||
|
|
||||||
namespace State.Game
|
namespace State.Game
|
||||||
{
|
{
|
||||||
public class MainMenuState : GameState
|
public class MainMenuState : MainGameState
|
||||||
{
|
{
|
||||||
|
private MainMenu _mainMenuInstance;
|
||||||
public override void OnEnter(Machine machine)
|
public override void OnEnter(Machine machine)
|
||||||
{
|
{
|
||||||
base.OnEnter(machine);
|
base.OnEnter(machine);
|
||||||
SceneManager.LoadScene("MainMenu", LoadSceneMode.Additive);
|
var handle = SceneManager.LoadSceneAsync("MainMenu", LoadSceneMode.Additive);
|
||||||
|
machine.StartCoroutine(LoadMenu(handle));
|
||||||
|
}
|
||||||
|
|
||||||
|
private IEnumerator LoadMenu(AsyncOperation handle)
|
||||||
|
{
|
||||||
|
while (!handle.isDone)
|
||||||
|
{
|
||||||
|
yield return null;
|
||||||
|
}
|
||||||
|
|
||||||
SceneManager.SetActiveScene(SceneManager.GetSceneByName("MainMenu"));
|
SceneManager.SetActiveScene(SceneManager.GetSceneByName("MainMenu"));
|
||||||
|
_mainMenuInstance = Object.Instantiate(MainStateMachine.MainMenuPrefab).GetComponent<MainMenu>();
|
||||||
|
if (_mainMenuInstance == null)
|
||||||
|
{
|
||||||
|
Debug.LogError("Error: MainMenu instance is null");
|
||||||
|
}
|
||||||
|
|
||||||
|
_mainMenuInstance.OnStartGame += HandleStartGame;
|
||||||
|
_mainMenuInstance.OnExitGame += () =>
|
||||||
|
{
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
UnityEditor.EditorApplication.isPlaying = false;
|
||||||
|
#else
|
||||||
|
Application.Quit();
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void OnExit()
|
||||||
|
{
|
||||||
|
Object.Destroy(_mainMenuInstance.gameObject);
|
||||||
|
base.OnExit();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void HandleStartGame()
|
||||||
|
{
|
||||||
|
_mainMenuInstance.OnStartGame -= HandleStartGame;
|
||||||
|
Debug.Log("Starting game");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
11
Assets/Scripts/State/Game/MainStateMachine.cs
Normal file
11
Assets/Scripts/State/Game/MainStateMachine.cs
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace State.Game
|
||||||
|
{
|
||||||
|
public class MainStateMachine : Machine
|
||||||
|
{
|
||||||
|
public GameObject MainMenuPrefab => mainMenuPrefab;
|
||||||
|
|
||||||
|
[SerializeField] private GameObject mainMenuPrefab;
|
||||||
|
}
|
||||||
|
}
|
||||||
3
Assets/Scripts/State/Game/MainStateMachine.cs.meta
Normal file
3
Assets/Scripts/State/Game/MainStateMachine.cs.meta
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 8ceca53f0e424e51a6c75d7a4bd1074d
|
||||||
|
timeCreated: 1777055906
|
||||||
8
Assets/Scripts/UI.meta
Normal file
8
Assets/Scripts/UI.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 53bd1392872c7b945bfd564da3f84986
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
33
Assets/Scripts/UI/MainMenu.cs
Normal file
33
Assets/Scripts/UI/MainMenu.cs
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
using System;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.UIElements;
|
||||||
|
|
||||||
|
namespace UI
|
||||||
|
{
|
||||||
|
[RequireComponent(typeof(UIDocument))]
|
||||||
|
public class MainMenu : MonoBehaviour
|
||||||
|
{
|
||||||
|
public event Action OnStartGame;
|
||||||
|
public event Action OnExitGame;
|
||||||
|
|
||||||
|
private Button _startGameButton;
|
||||||
|
private Button _exitGameButton;
|
||||||
|
|
||||||
|
private void Awake()
|
||||||
|
{
|
||||||
|
_startGameButton = GetComponent<UIDocument>().rootVisualElement.Q<Button>("StartGameButton");
|
||||||
|
_exitGameButton = GetComponent<UIDocument>().rootVisualElement.Q<Button>("QuitGameButton");
|
||||||
|
_startGameButton.clicked += HandleStartGame;
|
||||||
|
_exitGameButton.clicked += () => OnExitGame?.Invoke();
|
||||||
|
}
|
||||||
|
private void OnDestroy()
|
||||||
|
{
|
||||||
|
_startGameButton.clicked -= HandleStartGame;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void HandleStartGame()
|
||||||
|
{
|
||||||
|
OnStartGame?.Invoke();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
2
Assets/Scripts/UI/MainMenu.cs.meta
Normal file
2
Assets/Scripts/UI/MainMenu.cs.meta
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 313c38e8548656447b712e4191d6e57c
|
||||||
Loading…
x
Reference in New Issue
Block a user