浏览代码

Refactor part 3

/UI
Ciro Continisio 4 年前
当前提交
dcf0b00e
共有 11 个文件被更改,包括 89 次插入1105 次删除
  1. 998
      UOP1_Project/Assets/Scenes/Locations/Beach.unity
  2. 2
      UOP1_Project/Assets/Scenes/Managers/PersistentManagers.unity
  3. 2
      UOP1_Project/Assets/Scripts/Events/ScriptableObjects/LoadEventChannelSO.cs
  4. 15
      UOP1_Project/Assets/Scripts/SceneManagement/SceneLoader.cs
  5. 30
      UOP1_Project/Assets/Scripts/SceneManagement/SceneReadyBroadcaster.cs
  6. 6
      UOP1_Project/Assets/Scripts/SceneManagement/SceneReadyBroadcaster.cs.meta
  7. 49
      UOP1_Project/Assets/Prefabs/Gameplay/SceneStartup.prefab
  8. 66
      UOP1_Project/Assets/Prefabs/Gameplay/LocationEditorInitializer.prefab
  9. 11
      UOP1_Project/Assets/Scripts/SceneManagement/EditorInitialisationLoader.cs.meta
  10. 15
      UOP1_Project/Assets/Scripts/SceneManagement/EditorInitialisationLoader.cs
  11. 0
      /UOP1_Project/Assets/Prefabs/Gameplay/SceneStartup.prefab.meta

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

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


_gameplayScene: {fileID: 11400000, guid: a9c92d087d242344388972b3d1c4aaae, type: 2}
_loadLocation: {fileID: 11400000, guid: 00e3063edc5902e40832ea618644c597, type: 2}
_loadMenu: {fileID: 11400000, guid: 33cec85652903d245b99985f9cec9841, type: 2}
_editorColdStartup: {fileID: 11400000, guid: ca26ef526e415174a9309ac5cf5a1ce5, type: 2}
_onFade: {fileID: 11400000, guid: b40bb60f3ca40164e9d7acc6992bae10, type: 2}
--- !u!4 &1416216799
Transform:
m_ObjectHideFlags: 0

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


{
public UnityAction<GameSceneSO[], bool> OnLoadingRequested;
public void RaiseEvent(GameSceneSO[] locationsToLoad, bool showLoadingScreen)
public void RaiseEvent(GameSceneSO[] locationsToLoad, bool showLoadingScreen = false)
{
if (OnLoadingRequested != null)
{

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


[Header("Load Events")]
[SerializeField] private LoadEventChannelSO _loadLocation = default;
[SerializeField] private LoadEventChannelSO _loadMenu = default;
#if UNITY_EDITOR
[SerializeField] private LoadEventChannelSO _editorColdStartup = default;
#endif
[SerializeField] private FadeChannelSO _onFade = default;
private List<AsyncOperationHandle<SceneInstance>> _loadingOperationHandles = new List<AsyncOperationHandle<SceneInstance>>();
private AsyncOperationHandle<SceneInstance> _gameplayManagerLoadingOpHandle;

}
/// <summary>
/// This function loads the menu scenes passed as array parameter
/// Prepares to load the main menu scene, first removing the Gameplay scene in case the game is coming back from gameplay to menus.
/// </summary>
private void LoadMenu(GameSceneSO[] menusToLoad, bool showLoadingScreen)
{

UnloadPreviousScenes();
}
/// <summary>
/// In both Location and Menu loading, this function takes care of removing previously loaded temporary scenes.
/// </summary>
private void UnloadPreviousScenes()
{
for (int i = 0; i < _currentlyLoadedScenes.Length; i++)

LoadNewScenes();
}
/// <summary>
/// Kicks off the asynchronous loading of an array of scenes, either menus or Locations.
/// </summary>
private void LoadNewScenes()
{
if (_showLoadingScreen)

Scene s = ((SceneInstance)_loadingOperationHandles[0].Result).Scene;
SceneManager.SetActiveScene(s);
// Will reconstruct LightProbe tetrahedrons to include the probes from the newly-loaded scene
_onSceneReady.RaiseEvent();
_onSceneReady.RaiseEvent(); //Spawn system will spawn the PigChef
}
private void ExitGame()

30
UOP1_Project/Assets/Scripts/SceneManagement/SceneReadyBroadcaster.cs


using UnityEngine;
using UnityEditor;
using UnityEngine;
using UnityEngine.ResourceManagement.AsyncOperations;
using UnityEngine.ResourceManagement.ResourceProviders;
using UnityEngine.SceneManagement;
/// <summary>
/// This class manages the case we are in editor and we want to press play from any scene

public class SceneReadyBroadcaster : MonoBehaviour
{
[SerializeField] private VoidEventChannelSO _onSceneReady = default;
[Header("Broadcasting on")]
[SerializeField] private VoidEventChannelSO _OnSceneReady = default;
[Header("Editor cold-startup settings")]
[SerializeField] private GameSceneSO _thisSceneSO = default;
[SerializeField] private GameSceneSO _persistentManagersScene = default;
[SerializeField] private LoadEventChannelSO _loadSceneEventChannel = default;
#endif
if(GetComponent<EditorInitialisationLoader>()._shootEvent == true)
{
_OnSceneReady.RaiseEvent();
}
#if UNITY_EDITOR
_persistentManagersScene.sceneReference.LoadSceneAsync(LoadSceneMode.Additive, true).Completed += ReloadScene;
#endif
_onSceneReady.RaiseEvent();
#endif
private void ReloadScene(AsyncOperationHandle<SceneInstance> obj)
{
_loadSceneEventChannel.RaiseEvent(new GameSceneSO[] { _thisSceneSO });
SceneManager.UnloadSceneAsync(_thisSceneSO.sceneReference.editorAsset.name);
}
}

6
UOP1_Project/Assets/Scripts/SceneManagement/SceneReadyBroadcaster.cs.meta


MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
defaultReferences:
- _onSceneReady: {fileID: 11400000, guid: b729e40fc41dd8b4ea7aaf5c857f7186, type: 2}
- _fakeLoadRequestChannel: {fileID: 11400000, guid: 00e3063edc5902e40832ea618644c597,
type: 2}
- _thisSceneSO: {instanceID: 0}
executionOrder: 0
icon: {instanceID: 0}
userData:

49
UOP1_Project/Assets/Prefabs/Gameplay/SceneStartup.prefab


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &40564194958535835
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 40564194958535909}
- component: {fileID: 7222522106795826365}
m_Layer: 0
m_Name: SceneStartup
m_TagString: EditorOnly
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &40564194958535909
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 40564194958535835}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &7222522106795826365
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 40564194958535835}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: ca77942077a1ca846af4cc29b07958a8, type: 3}
m_Name:
m_EditorClassIdentifier:
_onSceneReady: {fileID: 11400000, guid: b729e40fc41dd8b4ea7aaf5c857f7186, type: 2}
_fakeLoadRequestChannel: {fileID: 11400000, guid: ca26ef526e415174a9309ac5cf5a1ce5,
type: 2}
_thisSceneSO: {fileID: 0}

66
UOP1_Project/Assets/Prefabs/Gameplay/LocationEditorInitializer.prefab


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &40564194958535835
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 40564194958535909}
- component: {fileID: 40564194958535908}
- component: {fileID: 7222522106795826365}
m_Layer: 0
m_Name: LocationEditorInitializer
m_TagString: EditorOnly
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &40564194958535909
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 40564194958535835}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &40564194958535908
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 40564194958535835}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: afdc0d26809578642bceb401301d2a8a, type: 3}
m_Name:
m_EditorClassIdentifier:
scenesToLoad:
- {fileID: 11400000, guid: c2119785ce96367428081d6eee0d932b, type: 2}
- {fileID: 11400000, guid: a9c92d087d242344388972b3d1c4aaae, type: 2}
targetFramerate: 0
_isEditorInitializerMode: 0
_OnEditorInitializer: {fileID: 11400000, guid: 13c350be03ed8f54cbc7630aa33b3d7b,
type: 2}
--- !u!114 &7222522106795826365
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 40564194958535835}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: ca77942077a1ca846af4cc29b07958a8, type: 3}
m_Name:
m_EditorClassIdentifier:
_OnSceneReady: {fileID: 11400000, guid: b729e40fc41dd8b4ea7aaf5c857f7186, type: 2}

11
UOP1_Project/Assets/Scripts/SceneManagement/EditorInitialisationLoader.cs.meta


fileFormatVersion: 2
guid: afdc0d26809578642bceb401301d2a8a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: -1100
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

15
UOP1_Project/Assets/Scripts/SceneManagement/EditorInitialisationLoader.cs


using UnityEngine;
using UnityEngine.SceneManagement;
/// <summary>
/// This script loads the persistent managers and gameplay Scenes, to allow to start the game from any gameplay Scene
/// It can also be used for menu scene by just adding the persistent managers scene on the inspector
/// </summary>
public class EditorInitialisationLoader : MonoBehaviour
{
#if UNITY_EDITOR
public int targetFramerate = 0; // For debugging purposes
//bool to know if we are coming from editor initializer mode
[HideInInspector] public bool _shootEvent = true;
#endif
}

/UOP1_Project/Assets/Prefabs/Gameplay/LocationEditorInitializer.prefab.meta → /UOP1_Project/Assets/Prefabs/Gameplay/SceneStartup.prefab.meta

正在加载...
取消
保存