Fix scene load arguments

This commit is contained in:
2022-08-14 16:49:18 -07:00
parent fd1cfa36d5
commit e1ae7deba5
10 changed files with 30 additions and 19 deletions

View File

@@ -1697,7 +1697,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!114 &2050966537
MonoBehaviour:
m_ObjectHideFlags: 0

View File

@@ -130,6 +130,10 @@ PrefabInstance:
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 5353799689805060140, guid: cdecf5aa30b8c3649aa7cc748758d68a, type: 3}
propertyPath: scene
value: TempleB
objectReference: {fileID: 0}
- target: {fileID: 5353799689805060140, guid: cdecf5aa30b8c3649aa7cc748758d68a, type: 3}
propertyPath: spawnPoint
value:

View File

@@ -746,7 +746,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
spawnPoint: {fileID: 361166861}
sceneIndex: 2
scene: TempleC
--- !u!23 &1156064028215898908
MeshRenderer:
m_ObjectHideFlags: 0
@@ -970,7 +970,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
spawnPoint: {fileID: 1864713635}
sceneIndex: 0
scene: TempleB
--- !u!65 &4444024360594741996
BoxCollider:
m_ObjectHideFlags: 0

View File

@@ -799,6 +799,10 @@ PrefabInstance:
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3124016421593227013, guid: 285b65b1583472147a5dcee7cfb4a4e0, type: 3}
propertyPath: scene
value: TempleD
objectReference: {fileID: 0}
- target: {fileID: 3124016421593227013, guid: 285b65b1583472147a5dcee7cfb4a4e0, type: 3}
propertyPath: sceneIndex
value: 3
@@ -931,6 +935,10 @@ PrefabInstance:
propertyPath: m_Enabled
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5353799689805060140, guid: cdecf5aa30b8c3649aa7cc748758d68a, type: 3}
propertyPath: scene
value: TempleB
objectReference: {fileID: 0}
- target: {fileID: 5353799689805060140, guid: cdecf5aa30b8c3649aa7cc748758d68a, type: 3}
propertyPath: spawnPoint
value:

View File

@@ -479,7 +479,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
spawnPoint: {fileID: 524613079}
sceneIndex: 2
scene: TempleC
--- !u!1 &705507993
GameObject:
m_ObjectHideFlags: 0

View File

@@ -8,7 +8,7 @@ namespace Scampz.GameJam
{
void Start()
{
GameManager.Instance.LoadScene(SceneManager.GetSceneByName(SceneNames.TempleC), LoadSceneMode.Additive);
GameManager.Instance.LoadScene(SceneNames.TempleC, LoadSceneMode.Additive);
}
}
}

View File

@@ -17,21 +17,21 @@ namespace Scampz.GameJam
}
}
public void LoadScene(Scene scene, LoadSceneMode loadSceneMode)
public void LoadScene(string sceneName, LoadSceneMode loadSceneMode)
{
StartCoroutine(LoadSceneAsync(scene, loadSceneMode));
StartCoroutine(LoadSceneAsync(sceneName, loadSceneMode));
}
public void UnloadScene(Scene scene)
public void UnloadScene(string sceneName)
{
StartCoroutine(UnloadSceneAsync(scene));
StartCoroutine(UnloadSceneAsync(sceneName));
}
private IEnumerator LoadSceneAsync(Scene scene, LoadSceneMode loadSceneMode)
private IEnumerator LoadSceneAsync(string sceneName, LoadSceneMode loadSceneMode)
{
yield return null;
var loadSceneOperation = SceneManager.LoadSceneAsync(scene.name, loadSceneMode);
var loadSceneOperation = SceneManager.LoadSceneAsync(sceneName, loadSceneMode);
loadSceneOperation.allowSceneActivation = false;
while (!loadSceneOperation.isDone)
{
@@ -43,11 +43,11 @@ namespace Scampz.GameJam
yield return loadSceneOperation;
}
private IEnumerator UnloadSceneAsync(Scene scene)
private IEnumerator UnloadSceneAsync(string sceneName)
{
yield return null;
if (SceneManager.GetSceneByName(scene.name).IsValid())
SceneManager.UnloadSceneAsync(scene);
if (SceneManager.GetSceneByName(sceneName).IsValid())
SceneManager.UnloadSceneAsync(sceneName);
}
}
}

View File

@@ -9,7 +9,7 @@ namespace Scampz.GameJam
private bool loaded = false;
public Transform spawnPoint;
[SerializeField]
public int scene;
private string scene;
void OnTriggerEnter(Collider collider)
{
@@ -19,7 +19,7 @@ namespace Scampz.GameJam
var player = GameObject.FindWithTag("Player");
var cc = player.GetComponent<CharacterController>();
cc.enabled = false;
GameManager.Instance.LoadScene(SceneManager.GetSceneByName(SceneNames.TempleA), LoadSceneMode.Additive);
GameManager.Instance.LoadScene(scene, LoadSceneMode.Additive);
player.transform.position = spawnPoint.position;
player.transform.rotation = spawnPoint.rotation;
cc.enabled = true;

View File

@@ -10,7 +10,7 @@ namespace Scampz.GameJam
{
if (Input.GetButtonDown(InputOptions.Submit))
{
GameManager.Instance.LoadScene(SceneManager.GetSceneByName(SceneNames.BaseScene), LoadSceneMode.Single);
GameManager.Instance.LoadScene(SceneNames.BaseScene, LoadSceneMode.Single);
}
}
}

View File

@@ -1,12 +1,11 @@
using UnityEngine;
using UnityEngine.SceneManagement;
namespace Scampz.GameJam
{
public class UnloadScene : MonoBehaviour
{
[SerializeField]
public Scene scene;
private string scene;
private bool unloaded = false;
void OnTriggerEnter(Collider collider)