浏览代码

Merge branch 'main' into UI

/UI
uChema 4 年前
当前提交
5d435a5e
共有 26 个文件被更改,包括 1210 次插入241 次删除
  1. 5
      UOP1_Project/Assets/Prefabs/Gameplay/EditorInitializer.prefab
  2. 14
      UOP1_Project/Assets/Scenes/Initialization.unity
  3. 9
      UOP1_Project/Assets/Scenes/Locations/Beach.unity
  4. 3
      UOP1_Project/Assets/Scenes/Locations/Forest.unity
  5. 3
      UOP1_Project/Assets/Scenes/Locations/Glade.unity
  6. 16
      UOP1_Project/Assets/Scenes/Managers/PersistentManagers.unity
  7. 89
      UOP1_Project/Assets/Scenes/Menus/MainMenu.unity
  8. 3
      UOP1_Project/Assets/Scenes/WIP/TestingGround.unity
  9. 10
      UOP1_Project/Assets/Scripts/Events/ScriptableObjects/LoadEventChannelSO.cs
  10. 4
      UOP1_Project/Assets/Scripts/SaveSystem/FileManager.cs
  11. 12
      UOP1_Project/Assets/Scripts/SaveSystem/SaveSystem.cs
  12. 12
      UOP1_Project/Assets/Scripts/SceneManagement/EditorColdStartup.cs
  13. 9
      UOP1_Project/Assets/Scripts/SceneManagement/InitializationLoader.cs
  14. 4
      UOP1_Project/Assets/Scripts/SceneManagement/LocationExit.cs
  15. 127
      UOP1_Project/Assets/Scripts/SceneManagement/SceneLoader.cs
  16. 3
      UOP1_Project/Assets/Scripts/SceneManagement/SceneLoader.cs.meta
  17. 6
      UOP1_Project/Assets/Scripts/SceneManagement/StartGame.cs
  18. 83
      UOP1_Project/ProjectSettings/ProjectSettings.asset
  19. 6
      UOP1_Project/Assets/Scripts/Animation/RandomIdleAnimationBehaviour.cs
  20. 1001
      Docs/ReadmeImages/Devlog4_Header.png
  21. 16
      UOP1_Project/Assets/ScriptableObjects/EventChannels/ColdStartup_Channel.asset
  22. 8
      UOP1_Project/Assets/ScriptableObjects/EventChannels/ColdStartup_Channel.asset.meta
  23. 8
      UOP1_Project/Assets/Scripts/Animation.meta
  24. 0
      /UOP1_Project/Assets/Scripts/Animation/RandomIdleAnimationBehaviour.cs
  25. 0
      /UOP1_Project/Assets/Scripts/Animation/RandomIdleAnimationBehaviour.cs.meta

5
UOP1_Project/Assets/Prefabs/Gameplay/EditorInitializer.prefab


_thisSceneSO: {fileID: 0}
_persistentManagersSO: {fileID: 11400000, guid: c2119785ce96367428081d6eee0d932b,
type: 2}
_loadSceneEventChannel:
m_AssetGUID: 00e3063edc5902e40832ea618644c597
_notifyColdStartupChannel:
m_AssetGUID: 8ebfc71cf11d0ed48b2207c447690115
m_EditorAssetChanged: 0

14
UOP1_Project/Assets/Scenes/Initialization.unity


--- !u!157 &3
LightmapSettings:
m_ObjectHideFlags: 0
serializedVersion: 11
serializedVersion: 12
m_GIWorkflowMode: 1
m_GISettings:
serializedVersion: 2

m_TrainingDataDestination: TrainingData
m_LightProbeSampleCountMultiplier: 4
m_LightingDataAsset: {fileID: 0}
m_UseShadowmask: 1
m_LightingSettings: {fileID: 0}
--- !u!196 &4
NavMeshSettings:
serializedVersion: 2

manualTileSize: 0
tileSize: 256
accuratePlacement: 0
maxJobWorkers: 0
preserveTilesOutsideBounds: 0
debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}

m_Script: {fileID: 11500000, guid: 43bf3a70578af0044a7af79dd1c44ea6, type: 3}
m_Name:
m_EditorClassIdentifier:
_persistentManagersScene: {fileID: 11400000, guid: c2119785ce96367428081d6eee0d932b,
type: 2}
_menuToLoad:
- {fileID: 11400000, guid: 431ff81b74b48fb4d9301fb76ca633dd, type: 2}
_showLoadScreen: 1
_managersScene: {fileID: 11400000, guid: c2119785ce96367428081d6eee0d932b, type: 2}
_menuToLoad: {fileID: 11400000, guid: 431ff81b74b48fb4d9301fb76ca633dd, type: 2}
m_EditorAssetChanged: 0
--- !u!4 &1266309721
Transform:
m_ObjectHideFlags: 0

9
UOP1_Project/Assets/Scenes/Locations/Beach.unity


m_Script: {fileID: 11500000, guid: 02e6b73898a4a52438d630a7ba29da77, type: 3}
m_Name:
m_EditorClassIdentifier:
_locationsToLoad:
- {fileID: 11400000, guid: d102ba8fe3b291249aeb9de4b95c1904, type: 2}
_locationToLoad: {fileID: 11400000, guid: d102ba8fe3b291249aeb9de4b95c1904, type: 2}
_showLoadScreen: 1
_pathTaken: {fileID: 11400000, guid: a9ec09853cba047a8a58f5881053cfc6, type: 2}
_exitPath: {fileID: 11400000, guid: 050fcf2d8a1044670b51fc2358167588, type: 2}

m_Script: {fileID: 11500000, guid: 02e6b73898a4a52438d630a7ba29da77, type: 3}
m_Name:
m_EditorClassIdentifier:
_locationsToLoad:
- {fileID: 11400000, guid: 3902a4362b3a4fb4ab5ce5dcc07d8427, type: 2}
_locationToLoad: {fileID: 11400000, guid: 3902a4362b3a4fb4ab5ce5dcc07d8427, type: 2}
_showLoadScreen: 1
_pathTaken: {fileID: 11400000, guid: a9ec09853cba047a8a58f5881053cfc6, type: 2}
_exitPath: {fileID: 11400000, guid: 447b413e95f8c95489b5385f03982ec5, type: 2}

m_Script: {fileID: 11500000, guid: 02e6b73898a4a52438d630a7ba29da77, type: 3}
m_Name:
m_EditorClassIdentifier:
_locationsToLoad:
- {fileID: 11400000, guid: 1514f833150a79e4c9d242f58bdbcbc0, type: 2}
_locationToLoad: {fileID: 11400000, guid: 1514f833150a79e4c9d242f58bdbcbc0, type: 2}
_showLoadScreen: 0
_pathTaken: {fileID: 11400000, guid: a9ec09853cba047a8a58f5881053cfc6, type: 2}
_exitPath: {fileID: 11400000, guid: 02c13d612a86149a8b354b877b9f261f, type: 2}

3
UOP1_Project/Assets/Scenes/Locations/Forest.unity


m_Script: {fileID: 11500000, guid: 02e6b73898a4a52438d630a7ba29da77, type: 3}
m_Name:
m_EditorClassIdentifier:
_locationsToLoad:
- {fileID: 11400000, guid: 2f386bbc670c05145834a0f9c7d55798, type: 2}
_locationToLoad: {fileID: 11400000, guid: 2f386bbc670c05145834a0f9c7d55798, type: 2}
_showLoadScreen: 0
_pathTaken: {fileID: 11400000, guid: a9ec09853cba047a8a58f5881053cfc6, type: 2}
_exitPath: {fileID: 11400000, guid: 050fcf2d8a1044670b51fc2358167588, type: 2}

3
UOP1_Project/Assets/Scenes/Locations/Glade.unity
文件差异内容过多而无法显示
查看文件

16
UOP1_Project/Assets/Scenes/Managers/PersistentManagers.unity


--- !u!157 &3
LightmapSettings:
m_ObjectHideFlags: 0
serializedVersion: 11
serializedVersion: 12
m_GIWorkflowMode: 1
m_GISettings:
serializedVersion: 2

m_TrainingDataDestination: TrainingData
m_LightProbeSampleCountMultiplier: 4
m_LightingDataAsset: {fileID: 0}
m_UseShadowmask: 1
m_LightingSettings: {fileID: 0}
--- !u!196 &4
NavMeshSettings:
serializedVersion: 2

manualTileSize: 0
tileSize: 256
accuratePlacement: 0
maxJobWorkers: 0
preserveTilesOutsideBounds: 0
debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}

m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 0}
m_TargetAssemblyTypeName:
m_MethodName: ExitGame
m_Mode: 1
m_Arguments:

m_Material: {fileID: 0}
m_Color: {r: 0, g: 0, b: 0, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:

m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:

m_Material: {fileID: 0}
m_Color: {r: 0.4528302, g: 0.4528302, b: 0.4528302, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:

m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:

m_FallbackScreenDPI: 96
m_DefaultSpriteDPI: 96
m_DynamicPixelsPerUnit: 1
m_PresetInfoIsWorld: 0
--- !u!223 &1387982342
Canvas:
m_ObjectHideFlags: 0

_gameplayScene: {fileID: 11400000, guid: a9c92d087d242344388972b3d1c4aaae, type: 2}
_loadLocation: {fileID: 11400000, guid: 00e3063edc5902e40832ea618644c597, type: 2}
_loadMenu: {fileID: 11400000, guid: 33cec85652903d245b99985f9cec9841, type: 2}
_coldStartupLocation: {fileID: 11400000, guid: 8ebfc71cf11d0ed48b2207c447690115,
type: 2}
_toggleLoadingScreen: {fileID: 11400000, guid: ce8db9fc090944349ba225edb81028d4,
type: 2}
_onSceneReady: {fileID: 11400000, guid: b729e40fc41dd8b4ea7aaf5c857f7186, type: 2}

m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:

m_Material: {fileID: 0}
m_Color: {r: 0, g: 0, b: 0, a: 0}
m_RaycastTarget: 0
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 0
m_OnCullStateChanged:
m_PersistentCalls:

89
UOP1_Project/Assets/Scenes/Menus/MainMenu.unity


m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 821853654}
m_CullTransparentMesh: 0
--- !u!1001 &826448973
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 40564194958535835, guid: 54d1f8b93400ea64d97c276fab375df3,
type: 3}
propertyPath: m_Name
value: EditorInitializer
objectReference: {fileID: 0}
- target: {fileID: 40564194958535909, guid: 54d1f8b93400ea64d97c276fab375df3,
type: 3}
propertyPath: m_RootOrder
value: 1
objectReference: {fileID: 0}
- target: {fileID: 40564194958535909, guid: 54d1f8b93400ea64d97c276fab375df3,
type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 40564194958535909, guid: 54d1f8b93400ea64d97c276fab375df3,
type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 40564194958535909, guid: 54d1f8b93400ea64d97c276fab375df3,
type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 40564194958535909, guid: 54d1f8b93400ea64d97c276fab375df3,
type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 40564194958535909, guid: 54d1f8b93400ea64d97c276fab375df3,
type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 40564194958535909, guid: 54d1f8b93400ea64d97c276fab375df3,
type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 40564194958535909, guid: 54d1f8b93400ea64d97c276fab375df3,
type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 40564194958535909, guid: 54d1f8b93400ea64d97c276fab375df3,
type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 40564194958535909, guid: 54d1f8b93400ea64d97c276fab375df3,
type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 40564194958535909, guid: 54d1f8b93400ea64d97c276fab375df3,
type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7222522106795826365, guid: 54d1f8b93400ea64d97c276fab375df3,
type: 3}
propertyPath: _thisSceneSO
value:
objectReference: {fileID: 11400000, guid: 431ff81b74b48fb4d9301fb76ca633dd,
type: 2}
- target: {fileID: 7222522106795826365, guid: 54d1f8b93400ea64d97c276fab375df3,
type: 3}
propertyPath: _loadSceneEventChannel.m_AssetGUID
value: 33cec85652903d245b99985f9cec9841
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 54d1f8b93400ea64d97c276fab375df3, type: 3}
--- !u!1 &1228641979
GameObject:
m_ObjectHideFlags: 0

m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 4
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!81 &1419319622
AudioListener:

m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 3
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1806157292
GameObject:

m_Name:
m_EditorClassIdentifier:
onPlayButtonPress: {fileID: 11400000, guid: 00e3063edc5902e40832ea618644c597, type: 2}
locationsToLoad:
- {fileID: 11400000, guid: 2f386bbc670c05145834a0f9c7d55798, type: 2}
locationsToLoad: {fileID: 11400000, guid: 2f386bbc670c05145834a0f9c7d55798, type: 2}
showLoadScreen: 1
saveSystem: {fileID: 11400000, guid: edc355c4a7d5028408d322b90814e19e, type: 2}
startText: {fileID: 622178819}

- {fileID: 684748717}
- {fileID: 821853655}
m_Father: {fileID: 0}
m_RootOrder: 2
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}

3
UOP1_Project/Assets/Scenes/WIP/TestingGround.unity
文件差异内容过多而无法显示
查看文件

10
UOP1_Project/Assets/Scripts/Events/ScriptableObjects/LoadEventChannelSO.cs


using UnityEngine.Events;
/// <summary>
/// This class is a used for scene loading events.
/// Takes an array of the scenes we want to load and a bool to specify if we want to show a loading screen.
/// This class is used for scene-loading events.
/// Takes a GameSceneSO of the location or menu that needs to be loaded, and a bool to specify if a loading screen needs to display.
public UnityAction<GameSceneSO[], bool> OnLoadingRequested;
public UnityAction<GameSceneSO, bool> OnLoadingRequested;
public void RaiseEvent(GameSceneSO[] locationsToLoad, bool showLoadingScreen = false)
public void RaiseEvent(GameSceneSO locationToLoad, bool showLoadingScreen = false)
OnLoadingRequested.Invoke(locationsToLoad, showLoadingScreen);
OnLoadingRequested.Invoke(locationToLoad, showLoadingScreen);
}
else
{

4
UOP1_Project/Assets/Scripts/SaveSystem/FileManager.cs


}
catch (Exception e)
{
//Debug.LogError($"Failed to write to {fullPath} with exception {e}");
Debug.LogError($"Failed to write to {fullPath} with exception {e}");
return false;
}
}

}
catch (Exception e)
{
//Debug.LogError($"Failed to read from {fullPath} with exception {e}");
Debug.LogError($"Failed to read from {fullPath} with exception {e}");
result = "";
return false;
}

12
UOP1_Project/Assets/Scripts/SaveSystem/SaveSystem.cs


_loadLocation.OnLoadingRequested -= CacheLoadLocations;
}
private void CacheLoadLocations(GameSceneSO[] locationsToLoad, bool showLoadingScreen)
private void CacheLoadLocations(GameSceneSO locationsToLoad, bool showLoadingScreen)
LocationSO locationSo = locationsToLoad[0] as LocationSO;
if (locationSo)
LocationSO locationSO = locationsToLoad as LocationSO;
if (locationSO)
saveData._locationId = locationSo.Guid;
saveData._locationId = locationSO.Guid;
}
SaveDataToDisk();

yield return loadItemOperationHandle;
if (loadItemOperationHandle.Status == AsyncOperationStatus.Succeeded)
{
var itemSo = loadItemOperationHandle.Result;
_playerInventory.Add(itemSo, serializedItemStack.amount);
var itemSO = loadItemOperationHandle.Result;
_playerInventory.Add(itemSO, serializedItemStack.amount);
}
}
}

12
UOP1_Project/Assets/Scripts/SceneManagement/EditorColdStartup.cs


#if UNITY_EDITOR
[SerializeField] private GameSceneSO _thisSceneSO = default;
[SerializeField] private GameSceneSO _persistentManagersSO = default;
[SerializeField] private AssetReference _loadSceneEventChannel = default;
[SerializeField] private AssetReference _notifyColdStartupChannel = default;
private void Start()
{

private void LoadEventChannel(AsyncOperationHandle<SceneInstance> obj)
{
_loadSceneEventChannel.LoadAssetAsync<LoadEventChannelSO>().Completed += ReloadScene;
_notifyColdStartupChannel.LoadAssetAsync<LoadEventChannelSO>().Completed += OnNotifyChannelLoaded;
private void ReloadScene(AsyncOperationHandle<LoadEventChannelSO> obj)
private void OnNotifyChannelLoaded(AsyncOperationHandle<LoadEventChannelSO> obj)
LoadEventChannelSO loadEventChannelSO = (LoadEventChannelSO)_loadSceneEventChannel.Asset;
loadEventChannelSO.RaiseEvent(new GameSceneSO[] { _thisSceneSO });
SceneManager.UnloadSceneAsync(_thisSceneSO.sceneReference.editorAsset.name);
LoadEventChannelSO loadEventChannelSO = (LoadEventChannelSO)_notifyColdStartupChannel.Asset;
loadEventChannelSO.RaiseEvent(_thisSceneSO);
}
#endif
}

9
UOP1_Project/Assets/Scripts/SceneManagement/InitializationLoader.cs


public class InitializationLoader : MonoBehaviour
{
[Header("Persistent managers Scene")]
[SerializeField] private GameSceneSO _persistentManagersScene = default;
[Header("Loading settings")]
[SerializeField] private GameSceneSO[] _menuToLoad = default;
[SerializeField] private GameSceneSO _managersScene = default;
[SerializeField] private GameSceneSO _menuToLoad = default;
[Header("Broadcasting on")]
[SerializeField] private AssetReference _menuLoadChannel = default;

//Load the persistent managers scene
_persistentManagersScene.sceneReference.LoadSceneAsync(LoadSceneMode.Additive, true).Completed += LoadEventChannel;
_managersScene.sceneReference.LoadSceneAsync(LoadSceneMode.Additive, true).Completed += LoadEventChannel;
}
private void LoadEventChannel(AsyncOperationHandle<SceneInstance> obj)

4
UOP1_Project/Assets/Scripts/SceneManagement/LocationExit.cs


public class LocationExit : MonoBehaviour
{
[Header("Loading settings")]
[SerializeField] private GameSceneSO[] _locationsToLoad = default;
[SerializeField] private GameSceneSO _locationToLoad = default;
[SerializeField] private bool _showLoadScreen = default;
[SerializeField] private PathAnchor _pathTaken = default;
[SerializeField] private PathSO _exitPath = default;

if (other.CompareTag("Player"))
{
UpdatePathTaken();
_locationExitLoadChannel.RaiseEvent(_locationsToLoad, _showLoadScreen);
_locationExitLoadChannel.RaiseEvent(_locationToLoad, _showLoadScreen);
}
}

127
UOP1_Project/Assets/Scripts/SceneManagement/SceneLoader.cs


[Header("Load Events")]
[SerializeField] private LoadEventChannelSO _loadLocation = default;
[SerializeField] private LoadEventChannelSO _loadMenu = default;
[SerializeField] private LoadEventChannelSO _coldStartupLocation = default;
private List<AsyncOperationHandle<SceneInstance>> _loadingOperationHandles = new List<AsyncOperationHandle<SceneInstance>>();
private AsyncOperationHandle<SceneInstance> _loadingOperationHandle;
private GameSceneSO[] _scenesToLoad;
private GameSceneSO[] _currentlyLoadedScenes = new GameSceneSO[] { };
private GameSceneSO _sceneToLoad;
private GameSceneSO _currentlyLoadedScene;
private bool _showLoadingScreen;
private SceneInstance _gameplayManagerSceneInstance = new SceneInstance();

_loadLocation.OnLoadingRequested += LoadLocation;
_loadMenu.OnLoadingRequested += LoadMenu;
#if UNITY_EDITOR
_coldStartupLocation.OnLoadingRequested += LocationColdStartup;
#endif
}
private void OnDisable()

#if UNITY_EDITOR
_coldStartupLocation.OnLoadingRequested -= LocationColdStartup;
#endif
#if UNITY_EDITOR
/// <summary>
/// This special loading function is only used in the editor, when the developer presses Play in a Location scene, without passing by Initialisation.
/// </summary>
private void LocationColdStartup(GameSceneSO currentlyOpenedLocation, bool showLoadingScreen)
{
_currentlyLoadedScene = currentlyOpenedLocation;
//Gameplay managers is loaded synchronously
_gameplayManagerLoadingOpHandle = _gameplayScene.sceneReference.LoadSceneAsync(LoadSceneMode.Additive, true);
_gameplayManagerLoadingOpHandle.WaitForCompletion();
_gameplayManagerSceneInstance = _gameplayManagerLoadingOpHandle.Result;
StartGameplay();
}
#endif
private void LoadLocation(GameSceneSO[] locationsToLoad, bool showLoadingScreen)
private void LoadLocation(GameSceneSO locationToLoad, bool showLoadingScreen)
_scenesToLoad = locationsToLoad;
_sceneToLoad = locationToLoad;
//In case we are coming from the main menu, we need to load the persistent Gameplay manager scene first
//In case we are coming from the main menu, we need to load the Gameplay manager scene first
StartCoroutine(ProcessGameplaySceneLoading(locationsToLoad, showLoadingScreen));
_gameplayManagerLoadingOpHandle = _gameplayScene.sceneReference.LoadSceneAsync(LoadSceneMode.Additive, true);
_gameplayManagerLoadingOpHandle.Completed += OnGameplayMangersLoaded;
UnloadPreviousScenes();
UnloadPreviousScene();
private IEnumerator ProcessGameplaySceneLoading(GameSceneSO[] locationsToLoad, bool showLoadingScreen)
private void OnGameplayMangersLoaded(AsyncOperationHandle<SceneInstance> obj)
_gameplayManagerLoadingOpHandle = _gameplayScene.sceneReference.LoadSceneAsync(LoadSceneMode.Additive, true);
while (_gameplayManagerLoadingOpHandle.Status != AsyncOperationStatus.Succeeded)
{
yield return null;
}
UnloadPreviousScenes();
UnloadPreviousScene();
private void LoadMenu(GameSceneSO[] menusToLoad, bool showLoadingScreen)
private void LoadMenu(GameSceneSO menuToLoad, bool showLoadingScreen)
_scenesToLoad = menusToLoad;
_sceneToLoad = menuToLoad;
_showLoadingScreen = showLoadingScreen;
//In case we are coming from a Location back to the main menu, we need to get rid of the persistent Gameplay manager scene

UnloadPreviousScenes();
UnloadPreviousScene();
/// In both Location and Menu loading, this function takes care of removing previously loaded temporary scenes.
/// In both Location and Menu loading, this function takes care of removing previously loaded scenes.
private void UnloadPreviousScenes()
private void UnloadPreviousScene()
for (int i = 0; i < _currentlyLoadedScenes.Length; i++)
if(_currentlyLoadedScene != null) //would be null if the game was started in Initialisation
_currentlyLoadedScenes[i].sceneReference.UnLoadScene();
if(_currentlyLoadedScene.sceneReference.OperationHandle.IsValid())
{
//Unload the scene through its AssetReference, i.e. through the Addressable system
_currentlyLoadedScene.sceneReference.UnLoadScene();
}
#if UNITY_EDITOR
else
{
//Only used when, after a "cold start", the player moves to a new scene
//Since the AsyncOperationHandle has not been used (the scene was already open in the editor),
//the scene needs to be unloaded using regular SceneManager instead of as an Addressable
SceneManager.UnloadSceneAsync(_currentlyLoadedScene.sceneReference.editorAsset.name);
}
#endif
LoadNewScenes();
LoadNewScene();
/// Kicks off the asynchronous loading of an array of scenes, either menus or Locations.
/// Kicks off the asynchronous loading of a scene, either menu or Location.
private void LoadNewScenes()
private void LoadNewScene()
{
if (_showLoadingScreen)
{

_loadingOperationHandles.Clear();
//Build the array of handles of the temporary scenes to load
for (int i = 0; i < _scenesToLoad.Length; i++)
{
_loadingOperationHandles.Add(_scenesToLoad[i].sceneReference.LoadSceneAsync(LoadSceneMode.Additive, true, 0));
}
StartCoroutine(LoadingProcess());
_loadingOperationHandle = _sceneToLoad.sceneReference.LoadSceneAsync(LoadSceneMode.Additive, true, 0);
_loadingOperationHandle.Completed += OnNewSceneLoaded;
private IEnumerator LoadingProcess()
private void OnNewSceneLoaded(AsyncOperationHandle<SceneInstance> obj)
bool done = _loadingOperationHandles.Count == 0;
//This while will exit when all scenes requested have been unloaded
while (!done)
{
for (int i = 0; i < _loadingOperationHandles.Count; ++i)
{
if (_loadingOperationHandles[i].Status != AsyncOperationStatus.Succeeded)
{
break;
}
else
{
done = true;
}
}
yield return null;
}
_currentlyLoadedScenes = _scenesToLoad;
_currentlyLoadedScene = _sceneToLoad;
SetActiveScene();
if (_showLoadingScreen)

}
/// <summary>

{
//All the scenes have been loaded, so we assume the first in the array is ready to become the active scene
Scene s = ((SceneInstance)_loadingOperationHandles[0].Result).Scene;
Scene s = ((SceneInstance)_loadingOperationHandle.Result).Scene;
StartGameplay();
}
private void StartGameplay()
{
_onSceneReady.RaiseEvent(); //Spawn system will spawn the PigChef
}

3
UOP1_Project/Assets/Scripts/SceneManagement/SceneLoader.cs.meta


- _gameplayScene: {fileID: 11400000, guid: a9c92d087d242344388972b3d1c4aaae, type: 2}
- _loadLocation: {fileID: 11400000, guid: 00e3063edc5902e40832ea618644c597, type: 2}
- _loadMenu: {fileID: 11400000, guid: 33cec85652903d245b99985f9cec9841, type: 2}
- _coldStartupLocation: {fileID: 11400000, guid: 8ebfc71cf11d0ed48b2207c447690115,
type: 2}
- _onFade: {fileID: 11400000, guid: b40bb60f3ca40164e9d7acc6992bae10, type: 2}
executionOrder: 0
icon: {instanceID: 0}
userData:

6
UOP1_Project/Assets/Scripts/SceneManagement/StartGame.cs


public class StartGame : MonoBehaviour
{
public LoadEventChannelSO onPlayButtonPress;
public GameSceneSO[] locationsToLoad;
public GameSceneSO locationsToLoad;
public bool showLoadScreen;
public SaveSystem saveSystem;

yield return asyncOperationHandle;
if (asyncOperationHandle.Status == AsyncOperationStatus.Succeeded)
{
var locationSo = asyncOperationHandle.Result;
onPlayButtonPress.RaiseEvent(new[] { (GameSceneSO)locationSo }, showLoadScreen);
LocationSO locationSO = asyncOperationHandle.Result;
onPlayButtonPress.RaiseEvent(locationSO, showLoadScreen);
}
}
}

83
UOP1_Project/ProjectSettings/ProjectSettings.asset


--- !u!129 &1
PlayerSettings:
m_ObjectHideFlags: 0
serializedVersion: 20
serializedVersion: 22
productGUID: a82b413058b45c84898c272682e257ea
AndroidProfiler: 0
AndroidFilterTouchesWhenObscured: 0

m_StereoRenderingPath: 0
m_ActiveColorSpace: 1
m_MTRendering: 1
mipStripping: 0
numberOfMipsStripped: 0
m_StackTraceTypes: 010000000100000001000000010000000100000001000000
iosShowActivityIndicatorOnLoading: -1
androidShowActivityIndicatorOnLoading: -1

stadiaTargetFramerate: 0
vulkanNumSwapchainBuffers: 3
vulkanEnableSetSRGBWrite: 0
vulkanEnablePreTransform: 0
vulkanEnableLateAcquireNextImage: 0
m_SupportedAspectRatios:
4:3: 1

xboxOneDisableKinectGpuReservation: 1
xboxOneEnable7thCore: 1
vrSettings:
cardboard:
depthFormat: 0
enableTransitionView: 0
daydream:
depthFormat: 0
useSustainedPerformanceMode: 0
enableVideoLayer: 0
useProtectedVideoMemory: 0
minimumSupportedHeadTracking: 0
maximumSupportedHeadTracking: 1
hololens:
depthFormat: 1
depthBufferSharingEnabled: 1
lumin:
depthFormat: 0
frameTiming: 2
enableGLCache: 0
glCacheMaxBlobSize: 524288
glCacheMaxFileSize: 8388608
oculus:
sharedDepthBuffer: 1
dashSupport: 1
lowOverheadMode: 0
protectedContext: 0
v2Signing: 1
enable360StereoCapture: 0
isWsaHolographicRemotingEnabled: 0
enableFrameTimingStats: 0

androidMaxAspectRatio: 2.1
applicationIdentifier:
Standalone: com.openprojects.chopchop
buildNumber: {}
buildNumber:
Standalone: 0
iPhone: 0
tvOS: 0
overrideDefaultApplicationIdentifier: 0
AndroidBundleVersionCode: 1
AndroidMinSdkVersion: 19
AndroidTargetSdkVersion: 0

StripUnusedMeshComponents: 0
VertexChannelCompressionMask: 4054
iPhoneSdkVersion: 988
iOSTargetOSVersionString: 10.0
iOSTargetOSVersionString: 11.0
tvOSTargetOSVersionString: 10.0
tvOSTargetOSVersionString: 11.0
uIPrerenderedIcon: 0
uIRequiresPersistentWiFi: 0
uIRequiresFullScreen: 1

iOSLaunchScreeniPadFillPct: 100
iOSLaunchScreeniPadSize: 100
iOSLaunchScreeniPadCustomXibPath:
iOSUseLaunchScreenStoryboard: 0
iOSLaunchScreeniPadCustomStoryboardPath:
iOSDeviceRequirements: []
iOSURLSchemes: []
iOSBackgroundModes: 0

iOSRequireARKit: 0
iOSAutomaticallyDetectAndAddCapabilities: 1
appleEnableProMotion: 0
shaderPrecisionModel: 0
useCustomMainManifest: 0
useCustomLauncherManifest: 0
useCustomMainGradleTemplate: 0
useCustomLauncherGradleManifest: 0
useCustomBaseGradleTemplate: 0
useCustomGradlePropertiesTemplate: 0
useCustomProguardFile: 0
AndroidTargetArchitectures: 1
AndroidSplashScreenScale: 0
androidSplashScreen: {fileID: 0}

height: 180
banner: {fileID: 0}
androidGamepadSupportLevel: 0
AndroidMinifyWithR8: 0
AndroidMinifyRelease: 0
AndroidMinifyDebug: 0
AndroidValidateAppBundleSize: 1
AndroidAppBundleSizeToValidate: 100
m_BuildTargetIcons: []

m_BuildTargetGraphicsAPIs:
- m_BuildTarget: iOSSupport
m_APIs: 10000000
m_Automatic: 0
m_Automatic: 1
m_Automatic: 0
m_Automatic: 1
- m_BuildTarget: AndroidPlayer
m_APIs: 150000000b000000
m_Automatic: 0

- m_BuildTarget: Standalone
m_EncodingQuality: 1
m_BuildTargetGroupLightmapSettings: []
m_BuildTargetNormalMapEncoding: []
playModeTestRunnerEnabled: 0
runPlayModeTestAsEditModeTest: 0
actionOnDotNetUnhandledException: 1

cameraUsageDescription:
locationUsageDescription:
microphoneUsageDescription:
switchNMETAOverride:
switchNetLibKey:
switchSocketMemoryPoolSize: 6144
switchSocketAllocatorPoolSize: 128

switchUseGOLDLinker: 0
switchApplicationID: 0x01004b9000490000
switchNSODependencies:
switchTitleNames_0:

switchTitleNames_12:
switchTitleNames_13:
switchTitleNames_14:
switchTitleNames_15:
switchPublisherNames_0:
switchPublisherNames_1:
switchPublisherNames_2:

switchPublisherNames_12:
switchPublisherNames_13:
switchPublisherNames_14:
switchPublisherNames_15:
switchIcons_0: {fileID: 0}
switchIcons_1: {fileID: 0}
switchIcons_2: {fileID: 0}

switchIcons_12: {fileID: 0}
switchIcons_13: {fileID: 0}
switchIcons_14: {fileID: 0}
switchIcons_15: {fileID: 0}
switchSmallIcons_0: {fileID: 0}
switchSmallIcons_1: {fileID: 0}
switchSmallIcons_2: {fileID: 0}

switchSmallIcons_12: {fileID: 0}
switchSmallIcons_13: {fileID: 0}
switchSmallIcons_14: {fileID: 0}
switchSmallIcons_15: {fileID: 0}
switchManualHTML:
switchAccessibleURLs:
switchLegalInformation:

switchSocketInitializeEnabled: 1
switchNetworkInterfaceManagerInitializeEnabled: 1
switchPlayerConnectionEnabled: 1
switchUseNewStyleFilepaths: 0
ps4NPAgeRating: 12
ps4NPTitleSecret:
ps4NPTrophyPackPath:

webGLAnalyzeBuildSize: 0
webGLUseEmbeddedResources: 0
webGLCompressionFormat: 1
webGLWasmArithmeticExceptions: 0
webGLWasmStreaming: 0
webGLDecompressionFallback: 0
additionalCompilerArguments: {}
platformArchitecture: {}
scriptingBackend:
Standalone: 1

suppressCommonWarnings: 1
useDeterministicCompilation: 1
useReferenceAssemblies: 1
enableRoslynAnalyzers: 1
additionalIl2CppArgs:
scriptingRuntimeVersion: 1
gcIncremental: 0

XboxOneXTitleMemory: 8
XboxOneOverrideIdentityName:
XboxOneOverrideIdentityPublisher:
vrEditorSettings:
daydream:
daydreamIconForeground: {fileID: 0}
daydreamIconBackground: {fileID: 0}
vrEditorSettings: {}
cloudServicesEnabled:
UNet: 1
luminIcon:

m_VersionCode: 1
m_VersionName:
apiCompatibilityLevel: 6
activeInputHandler: 1
qualitySettingsNames: []
enableNativePlatformBackendsForNewInputSystem: 1
disableOldInputManagerSupport: 1
virtualTexturingSupportEnabled: 0

6
UOP1_Project/Assets/Scripts/Animation/RandomIdleAnimationBehaviour.cs


public class RandomIdleAnimationBehaviour : StateMachineBehaviour
{
override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
}
}
}

1001
Docs/ReadmeImages/Devlog4_Header.png
文件差异内容过多而无法显示
查看文件

16
UOP1_Project/Assets/ScriptableObjects/EventChannels/ColdStartup_Channel.asset


%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: 82df99cd4c7564d4ca44d50a1dce516b, type: 3}
m_Name: ColdStartup_Channel
m_EditorClassIdentifier:
description: Raised to notify the SceneLoader that the user has pressed Play in
the editor from a Location scene.

8
UOP1_Project/Assets/ScriptableObjects/EventChannels/ColdStartup_Channel.asset.meta


fileFormatVersion: 2
guid: 8ebfc71cf11d0ed48b2207c447690115
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

8
UOP1_Project/Assets/Scripts/Animation.meta


fileFormatVersion: 2
guid: a40233ca5f148cf4897ae71dc6d18b65
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

/UOP1_Project/Assets/RandomIdleAnimationBehaviour.cs → /UOP1_Project/Assets/Scripts/Animation/RandomIdleAnimationBehaviour.cs

/UOP1_Project/Assets/RandomIdleAnimationBehaviour.cs.meta → /UOP1_Project/Assets/Scripts/Animation/RandomIdleAnimationBehaviour.cs.meta

正在加载...
取消
保存