MAJOR: Re-organize entire project
This commit is contained in:
68
Assets/Scripts/GameManager/GameManager.cs
Normal file
68
Assets/Scripts/GameManager/GameManager.cs
Normal file
@@ -0,0 +1,68 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
namespace Scampz.GameJam
|
||||
{
|
||||
public class GameManager : MonoBehaviour
|
||||
{
|
||||
public static GameManager Instance;
|
||||
public Animator animator;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
if (Instance == null)
|
||||
{
|
||||
Instance = this;
|
||||
}
|
||||
}
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
//SceneManager.sceneLoaded += OnSceneLoaded;
|
||||
}
|
||||
|
||||
void OnDisable()
|
||||
{
|
||||
//SceneManager.sceneLoaded -= OnSceneLoaded;
|
||||
}
|
||||
|
||||
public void LoadScene(string sceneName, LoadSceneMode loadSceneMode)
|
||||
{
|
||||
StartCoroutine(LoadSceneAsync(sceneName, loadSceneMode));
|
||||
}
|
||||
|
||||
public void UnloadScene(string sceneName)
|
||||
{
|
||||
StartCoroutine(UnloadSceneAsync(sceneName));
|
||||
}
|
||||
|
||||
private IEnumerator LoadSceneAsync(string sceneName, LoadSceneMode loadSceneMode)
|
||||
{
|
||||
yield return null;
|
||||
|
||||
var loadSceneOperation = SceneManager.LoadSceneAsync(sceneName, loadSceneMode);
|
||||
loadSceneOperation.allowSceneActivation = false;
|
||||
while (!loadSceneOperation.isDone)
|
||||
{
|
||||
if (loadSceneOperation.progress >= 0.9f)
|
||||
break;
|
||||
}
|
||||
|
||||
loadSceneOperation.allowSceneActivation = true;
|
||||
yield return loadSceneOperation;
|
||||
}
|
||||
|
||||
private IEnumerator UnloadSceneAsync(string sceneName)
|
||||
{
|
||||
yield return null;
|
||||
if (SceneManager.GetSceneByName(sceneName).IsValid())
|
||||
SceneManager.UnloadSceneAsync(sceneName);
|
||||
}
|
||||
|
||||
private void OnSceneLoaded(Scene scene, LoadSceneMode loadSceneMode)
|
||||
{
|
||||
//BGMManager.Instance.PlaySong();
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/GameManager/GameManager.cs.meta
Normal file
11
Assets/Scripts/GameManager/GameManager.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 253db048700363d419cdd2430bb39594
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user