Ciro Continisio
4 年前
当前提交
577d1538
共有 19 个文件被更改,包括 111 次插入 和 152 次删除
-
7Assets/Prefabs/GameManager.prefab
-
2Assets/Prefabs/GameplayCanvas.prefab
-
4Assets/Prefabs/Player.prefab
-
1Assets/Scenes/LoadingScene.unity
-
87Assets/Scenes/MainMenu.unity
-
7Assets/Scripts/GameplayUI.cs
-
7Assets/Scripts/Loading.cs
-
5Assets/Scripts/PlayerController.cs
-
2Assets/Scripts/GameManagerMB.cs.meta
-
8Assets/ScriptableObjects.meta
-
9Assets/Scripts/GameManagerMB.cs
-
41Assets/Scripts/GameManagerSO.cs
-
17Assets/ScriptableObjects/GameManager.asset
-
8Assets/ScriptableObjects/GameManager.asset.meta
-
40Assets/Scripts/GameManager.cs
-
18Assets/Scripts/UISetup.cs
-
0/Assets/Scripts/GameManagerSO.cs.meta
-
0/Assets/Scripts/GameManagerMB.cs.meta
|
|||
fileFormatVersion: 2 |
|||
guid: 67daac2eb6d70c547a6061ea49ecfa32 |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using UnityEngine; |
|||
|
|||
public class GameManagerMB : MonoBehaviour |
|||
{ |
|||
[SerializeField] |
|||
private GameManagerSO m_GameManager; |
|||
} |
|
|||
using UnityEngine; |
|||
using UnityEngine.AddressableAssets; |
|||
|
|||
[CreateAssetMenu()] |
|||
public class GameManagerSO : ScriptableObject |
|||
{ |
|||
public int s_CurrentLevel = 0; |
|||
|
|||
public int s_MaxAvailableLevel = 4; |
|||
|
|||
public int s_ActiveHat; |
|||
|
|||
public void ExitGame() |
|||
{ |
|||
s_CurrentLevel = 0; |
|||
} |
|||
|
|||
public void LoadNextLevel() |
|||
{ |
|||
// We are going to be using the Addressables API to manage our scene loading and unloading, the equivalent way on the UnityEngine.SceneManagement API is:
|
|||
// SceneManager.LoadSceneAsync("LoadingScene", LoadSceneMode.Single);
|
|||
|
|||
// Scene loaded in Single mode, the previously loaded scenes will be disposed by the Addressables.
|
|||
Addressables.LoadSceneAsync("LoadingScene", UnityEngine.SceneManagement.LoadSceneMode.Single, true); |
|||
} |
|||
|
|||
public void LevelCompleted() |
|||
{ |
|||
s_CurrentLevel++; |
|||
|
|||
// Just to make sure we don't try to go beyond the allowed number of levels.
|
|||
s_CurrentLevel = s_CurrentLevel % s_MaxAvailableLevel; |
|||
|
|||
LoadNextLevel(); |
|||
} |
|||
|
|||
public void ExitGameplay() |
|||
{ |
|||
Addressables.LoadSceneAsync("MainMenu", UnityEngine.SceneManagement.LoadSceneMode.Single, true); |
|||
} |
|||
} |
|
|||
%YAML 1.1 |
|||
%TAG !u! tag:unity3d.com,2011: |
|||
--- !u!114 &11400000 |
|||
MonoBehaviour: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 0} |
|||
m_Enabled: 1 |
|||
m_EditorHideFlags: 0 |
|||
m_Script: {fileID: 11500000, guid: 9a82635b139e4af468b5fec0e262a853, type: 3} |
|||
m_Name: GameManager |
|||
m_EditorClassIdentifier: |
|||
s_CurrentLevel: 0 |
|||
s_MaxAvailableLevel: 4 |
|||
s_ActiveHat: 0 |
|
|||
fileFormatVersion: 2 |
|||
guid: a9f6da264584558478e57f0d26b9befb |
|||
NativeFormatImporter: |
|||
externalObjects: {} |
|||
mainObjectFileID: 0 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using UnityEngine; |
|||
using UnityEngine.AddressableAssets; |
|||
|
|||
public class GameManager : MonoBehaviour |
|||
{ |
|||
public static int s_CurrentLevel = 0; |
|||
|
|||
public static int s_MaxAvailableLevel = 4; |
|||
|
|||
public static int s_ActiveHat; |
|||
|
|||
public void ExitGame() |
|||
{ |
|||
s_CurrentLevel = 0; |
|||
} |
|||
|
|||
public static void LoadNextLevel() |
|||
{ |
|||
// We are going to be using the Addressables API to manage our scene loading and unloading, the equivalent way on the UnityEngine.SceneManagement API is:
|
|||
// SceneManager.LoadSceneAsync("LoadingScene", LoadSceneMode.Single);
|
|||
|
|||
// Scene loaded in Single mode, the previously loaded scenes will be disposed by the Addressables.
|
|||
Addressables.LoadSceneAsync("LoadingScene", UnityEngine.SceneManagement.LoadSceneMode.Single, true); |
|||
} |
|||
|
|||
public static void LevelCompleted() |
|||
{ |
|||
s_CurrentLevel++; |
|||
|
|||
// Just to make sure we don't try to go beyond the allowed number of levels.
|
|||
s_CurrentLevel = s_CurrentLevel % s_MaxAvailableLevel; |
|||
|
|||
LoadNextLevel(); |
|||
} |
|||
|
|||
public static void ExitGameplay() |
|||
{ |
|||
Addressables.LoadSceneAsync("MainMenu", UnityEngine.SceneManagement.LoadSceneMode.Single, true); |
|||
} |
|||
} |
|
|||
using UnityEngine; |
|||
using UnityEngine.UI; |
|||
|
|||
public class UISetup : MonoBehaviour |
|||
{ |
|||
[SerializeField] |
|||
private Button m_StartButton; |
|||
|
|||
private void OnEnable() |
|||
{ |
|||
m_StartButton.onClick.AddListener(GameManager.LoadNextLevel); |
|||
} |
|||
|
|||
private void OnDisable() |
|||
{ |
|||
m_StartButton.onClick.RemoveListener(GameManager.LoadNextLevel); |
|||
} |
|||
} |
撰写
预览
正在加载...
取消
保存
Reference in new issue