fade to correct scene when current scene doesn't match save file on load
This commit is contained in:
@@ -2984,17 +2984,6 @@ MeshFilter:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1286273673}
|
||||
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
|
||||
--- !u!114 &1299342542 stripped
|
||||
MonoBehaviour:
|
||||
m_CorrespondingSourceObject: {fileID: 7112063300641303959, guid: 6d1ef2b53d3ef0446852da522af66b73, type: 3}
|
||||
m_PrefabInstance: {fileID: 6325623361260993107}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.Button
|
||||
--- !u!1 &1316688875
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -3149,17 +3138,6 @@ Transform:
|
||||
- {fileID: 813193272}
|
||||
m_Father: {fileID: 265036979}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &1366274845 stripped
|
||||
MonoBehaviour:
|
||||
m_CorrespondingSourceObject: {fileID: 1356069847872831277, guid: 6d1ef2b53d3ef0446852da522af66b73, type: 3}
|
||||
m_PrefabInstance: {fileID: 6325623361260993107}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.Button
|
||||
--- !u!1 &1378316137
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -4156,17 +4134,6 @@ Transform:
|
||||
- {fileID: 441147620}
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &2079108456 stripped
|
||||
MonoBehaviour:
|
||||
m_CorrespondingSourceObject: {fileID: 4694531887666682614, guid: 6d1ef2b53d3ef0446852da522af66b73, type: 3}
|
||||
m_PrefabInstance: {fileID: 6325623361260993107}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.Button
|
||||
--- !u!1 &2146681811
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -4452,18 +4419,6 @@ PrefabInstance:
|
||||
propertyPath: m_LocalEulerAnglesHint.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8504793874200787636, guid: 6d1ef2b53d3ef0446852da522af66b73, type: 3}
|
||||
propertyPath: QuitButton
|
||||
value:
|
||||
objectReference: {fileID: 2079108456}
|
||||
- target: {fileID: 8504793874200787636, guid: 6d1ef2b53d3ef0446852da522af66b73, type: 3}
|
||||
propertyPath: SaveButton
|
||||
value:
|
||||
objectReference: {fileID: 1366274845}
|
||||
- target: {fileID: 8504793874200787636, guid: 6d1ef2b53d3ef0446852da522af66b73, type: 3}
|
||||
propertyPath: DeleteSaveButton
|
||||
value:
|
||||
objectReference: {fileID: 1299342542}
|
||||
m_RemovedComponents: []
|
||||
m_RemovedGameObjects: []
|
||||
m_AddedGameObjects: []
|
||||
|
||||
@@ -44,7 +44,6 @@ private void Awake()
|
||||
private void Start()
|
||||
{
|
||||
SaveSystem.Load();
|
||||
SaveSystem.Save(); // save off any corruption fixes
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -70,15 +69,15 @@ private void ReloadReferences()
|
||||
/// <summary>
|
||||
/// Triggers transition to a map point
|
||||
/// </summary>
|
||||
public void GoToMapPoint(MapPoint mapPoint)
|
||||
public void GoToMapPoint(MapPoint mapPoint, bool instantBlackScreen = false)
|
||||
{
|
||||
StartCoroutine(GoToMapPointCoroutine(mapPoint));
|
||||
StartCoroutine(GoToMapPointCoroutine(mapPoint, instantBlackScreen));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Executes transition to map point (scene and location)
|
||||
/// </summary>
|
||||
private IEnumerator GoToMapPointCoroutine(MapPoint mapPoint)
|
||||
private IEnumerator GoToMapPointCoroutine(MapPoint mapPoint, bool instantBlackScreen)
|
||||
{
|
||||
Instance.isTransitioningScenes = true;
|
||||
Instance.PlayerController.SetCharacterControl(false);
|
||||
@@ -89,6 +88,9 @@ private IEnumerator GoToMapPointCoroutine(MapPoint mapPoint)
|
||||
float fadeTime = 0;
|
||||
Color blackScreenColor = Color.black;
|
||||
|
||||
// Fade to black when instantBlackScreen is false
|
||||
if (!instantBlackScreen)
|
||||
{
|
||||
while (fadeTime < fadeDuration)
|
||||
{
|
||||
blackScreenColor.a = Mathf.Lerp(0, 1, fadeTime / fadeDuration);
|
||||
@@ -97,7 +99,13 @@ private IEnumerator GoToMapPointCoroutine(MapPoint mapPoint)
|
||||
yield return null;
|
||||
}
|
||||
fadeTime = 0;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// instantly make screen black before scene transition
|
||||
blackScreenColor.a = 1;
|
||||
Instance.BlackScreen.color = blackScreenColor;
|
||||
}
|
||||
|
||||
AsyncOperation asyncLoad = SceneManager.LoadSceneAsync(mapPoint.Scene);
|
||||
while (!asyncLoad.isDone)
|
||||
@@ -126,6 +134,9 @@ private IEnumerator GoToMapPointCoroutine(MapPoint mapPoint)
|
||||
yield return null;
|
||||
}
|
||||
|
||||
blackScreenColor.a = 0;
|
||||
Instance.BlackScreen.color = blackScreenColor;
|
||||
|
||||
// move character a little more
|
||||
while (fadeTime < moveDuration)
|
||||
{
|
||||
@@ -183,6 +194,7 @@ private IEnumerator EnterSceneDoorCoroutine(string scene, int doorId)
|
||||
ReloadReferences();
|
||||
|
||||
// Make sure screen is black in new scene
|
||||
blackScreenColor.a = 1;
|
||||
Instance.BlackScreen.color = blackScreenColor;
|
||||
|
||||
SceneDoor door = GameSceneManager.Instance.GetDoorWithId(doorId);
|
||||
@@ -207,6 +219,9 @@ private IEnumerator EnterSceneDoorCoroutine(string scene, int doorId)
|
||||
yield return null;
|
||||
}
|
||||
|
||||
blackScreenColor.a = 0;
|
||||
Instance.BlackScreen.color = blackScreenColor;
|
||||
|
||||
// move character a little more
|
||||
while (fadeTime < moveDuration)
|
||||
{
|
||||
|
||||
@@ -7,4 +7,10 @@ public class MapPoint
|
||||
{
|
||||
public string Scene;
|
||||
public Vector3 SpawnPosition;
|
||||
|
||||
public MapPoint(string scene, Vector3 spawnPosition)
|
||||
{
|
||||
this.Scene = scene;
|
||||
this.SpawnPosition = spawnPosition;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,15 +17,17 @@ public void SavePlayerData(ref PlayerSaveData data)
|
||||
|
||||
public void LoadPlayerData(PlayerSaveData data)
|
||||
{
|
||||
/*if (data.currentScene != null && data.currentScene != SceneManager.GetActiveScene().name)
|
||||
if (data.currentScene != null && data.currentScene != SceneManager.GetActiveScene().name)
|
||||
{
|
||||
GameManager.Instance.GoToMapPoint(new MapPoint(data.currentScene, data.dougPosition), true);
|
||||
}
|
||||
else
|
||||
{
|
||||
SceneManager.LoadScene(data.currentScene);
|
||||
}*/
|
||||
|
||||
GameManager.Instance.PlayerManager.CurrentToolIndex = data.activeToolIndex;
|
||||
GameManager.Instance.PlayerController.cameraController.SnapToRotation(data.camRotation);
|
||||
GameManager.Instance.PlayerController.transform.position = data.dougPosition;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user