浏览代码

Loading refactor part 4

/UI
Ciro Continisio 4 年前
当前提交
7eee90e5
共有 17 个文件被更改,包括 271 次插入461 次删除
  1. 22
      UOP1_Project/Assets/Scenes/Locations/Beach.unity
  2. 22
      UOP1_Project/Assets/Scenes/Locations/Glade.unity
  3. 287
      UOP1_Project/Assets/Scenes/Menus/MainMenu.unity
  4. 62
      UOP1_Project/Assets/Scenes/WIP/TestingGround.unity
  5. 8
      UOP1_Project/Assets/Scripts/Editor/SceneSelector/SceneSelector.Helper.cs
  6. 51
      UOP1_Project/Assets/Scripts/Editor/SceneSelector/SceneSelector.cs
  7. 11
      UOP1_Project/Assets/Scripts/SceneManagement/InitializationLoader.cs
  8. 3
      UOP1_Project/Assets/Scripts/SceneManagement/SceneLoader.cs
  9. 52
      UOP1_Project/Assets/Prefabs/Gameplay/EditorInitializer.prefab
  10. 38
      UOP1_Project/Assets/Scripts/SceneManagement/EditorColdStartup.cs
  11. 17
      UOP1_Project/Assets/Scripts/SceneManagement/EditorColdStartup.cs.meta
  12. 7
      UOP1_Project/Assets/Prefabs/Gameplay/MenuEditorInitializer.prefab.meta
  13. 51
      UOP1_Project/Assets/Prefabs/Gameplay/MenuEditorInitializer.prefab
  14. 49
      UOP1_Project/Assets/Prefabs/Gameplay/SceneStartup.prefab
  15. 37
      UOP1_Project/Assets/Scripts/SceneManagement/SceneReadyBroadcaster.cs
  16. 15
      UOP1_Project/Assets/Scripts/SceneManagement/SceneReadyBroadcaster.cs.meta
  17. 0
      /UOP1_Project/Assets/Prefabs/Gameplay/EditorInitializer.prefab.meta

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


- target: {fileID: 2125786285293829335, guid: e978d53d440e0814086759404585ac32,
type: 3}
propertyPath: m_RootOrder
value: 1
value: 2
objectReference: {fileID: 0}
- target: {fileID: 2125786285293829335, guid: e978d53d440e0814086759404585ac32,
type: 3}

- target: {fileID: 2808035858438402709, guid: 45632f0a227c860489bcba0eb1f4ec3e,
type: 3}
propertyPath: m_LocalRotation.y
value: 0.043281153
value: 0.043281112
value: -0.010424011
value: -0.010424001
objectReference: {fileID: 0}
- target: {fileID: 2955398947125553842, guid: 45632f0a227c860489bcba0eb1f4ec3e,
type: 3}

- target: {fileID: 2955398947125553842, guid: 45632f0a227c860489bcba0eb1f4ec3e,
type: 3}
propertyPath: m_LocalRotation.y
value: 0.043281153
value: 0.043281112
value: -0.010424011
value: -0.010424001
objectReference: {fileID: 0}
- target: {fileID: 8745341640208226293, guid: 45632f0a227c860489bcba0eb1f4ec3e,
type: 3}

- target: {fileID: 8745341642014614482, guid: 45632f0a227c860489bcba0eb1f4ec3e,
type: 3}
propertyPath: m_LocalRotation.y
value: 0.043281153
value: 0.043281112
value: -0.010424012
value: -0.010424003
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 45632f0a227c860489bcba0eb1f4ec3e, type: 3}

- target: {fileID: 40564194958535909, guid: 54d1f8b93400ea64d97c276fab375df3,
type: 3}
propertyPath: m_RootOrder
value: 2
value: 1
objectReference: {fileID: 0}
- target: {fileID: 40564194958535909, guid: 54d1f8b93400ea64d97c276fab375df3,
type: 3}

propertyPath: _thisSceneSO
value:
objectReference: {fileID: 11400000, guid: 2f386bbc670c05145834a0f9c7d55798,
type: 2}
- target: {fileID: 7222522106795826365, guid: 54d1f8b93400ea64d97c276fab375df3,
type: 3}
propertyPath: _loadSceneEventChannel
value:
objectReference: {fileID: 11400000, guid: 00e3063edc5902e40832ea618644c597,
type: 2}
- target: {fileID: 7222522106795826365, guid: 54d1f8b93400ea64d97c276fab375df3,
type: 3}

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

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


debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
--- !u!1 &384578945
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 384578947}
- component: {fileID: 384578946}
m_Layer: 0
m_Name: Directional Light
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!108 &384578946
Light:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 384578945}
m_Enabled: 1
serializedVersion: 10
m_Type: 1
m_Shape: 0
m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1}
m_Intensity: 1
m_Range: 10
m_SpotAngle: 30
m_InnerSpotAngle: 21.80208
m_CookieSize: 10
m_Shadows:
m_Type: 2
m_Resolution: -1
m_CustomResolution: -1
m_Strength: 1
m_Bias: 0.05
m_NormalBias: 0.4
m_NearPlane: 0.2
m_CullingMatrixOverride:
e00: 1
e01: 0
e02: 0
e03: 0
e10: 0
e11: 1
e12: 0
e13: 0
e20: 0
e21: 0
e22: 1
e23: 0
e30: 0
e31: 0
e32: 0
e33: 1
m_UseCullingMatrixOverride: 0
m_Cookie: {fileID: 0}
m_DrawHalo: 0
m_Flare: {fileID: 0}
m_RenderMode: 0
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_RenderingLayerMask: 1
m_Lightmapping: 4
m_LightShadowCasterMode: 0
m_AreaSize: {x: 1, y: 1}
m_BounceIntensity: 1
m_ColorTemperature: 6570
m_UseColorTemperature: 0
m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0}
m_UseBoundingSphereOverride: 0
m_ShadowRadius: 0
m_ShadowAngle: 0
--- !u!4 &384578947
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 384578945}
m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261}
m_LocalPosition: {x: 0, y: 3, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 1367871826}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}
--- !u!1 &403475996
GameObject:
m_ObjectHideFlags: 0

m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 403475996}
m_CullTransparentMesh: 0
--- !u!1001 &599522224
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 40564194958535835, guid: 0fa3e82c4006e714e8023cbf85cc999e,
type: 3}
propertyPath: m_Name
value: MenuEditorInitializer
objectReference: {fileID: 0}
- target: {fileID: 40564194958535909, guid: 0fa3e82c4006e714e8023cbf85cc999e,
type: 3}
propertyPath: m_RootOrder
value: 0
objectReference: {fileID: 0}
- target: {fileID: 40564194958535909, guid: 0fa3e82c4006e714e8023cbf85cc999e,
type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 40564194958535909, guid: 0fa3e82c4006e714e8023cbf85cc999e,
type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 40564194958535909, guid: 0fa3e82c4006e714e8023cbf85cc999e,
type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 40564194958535909, guid: 0fa3e82c4006e714e8023cbf85cc999e,
type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 40564194958535909, guid: 0fa3e82c4006e714e8023cbf85cc999e,
type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 40564194958535909, guid: 0fa3e82c4006e714e8023cbf85cc999e,
type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 40564194958535909, guid: 0fa3e82c4006e714e8023cbf85cc999e,
type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 40564194958535909, guid: 0fa3e82c4006e714e8023cbf85cc999e,
type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 40564194958535909, guid: 0fa3e82c4006e714e8023cbf85cc999e,
type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 40564194958535909, guid: 0fa3e82c4006e714e8023cbf85cc999e,
type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 0fa3e82c4006e714e8023cbf85cc999e, type: 3}
--- !u!1 &622178817
GameObject:
m_ObjectHideFlags: 0

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: 0
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_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: -123.1}
m_AnchoredPosition: {x: 0, y: -123.1001}
m_SizeDelta: {x: 0, y: 280.2737}
m_Pivot: {x: 0.5, y: 1}
--- !u!114 &1228641981

m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: -49.1}
m_AnchoredPosition: {x: 0, y: -49.100098}
m_SizeDelta: {x: 0, y: 157.00864}
m_Pivot: {x: 0.5, y: 1}
--- !u!114 &1312122617

m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1312122615}
m_CullTransparentMesh: 0
--- !u!1 &1367871825
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1367871826}
m_Layer: 0
m_Name: MainMenuElements
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1367871826
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1367871825}
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:
- {fileID: 384578947}
- {fileID: 2140469183}
- {fileID: 1577385654}
- {fileID: 1419319621}
m_Father: {fileID: 0}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1419319618
GameObject:
m_ObjectHideFlags: 0

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

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

m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
- m_Target: {fileID: 1367871825}
- m_Target: {fileID: 0}
m_MethodName: SetActive
m_Mode: 6
m_Arguments:

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

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

8
UOP1_Project/Assets/Scripts/Editor/SceneSelector/SceneSelector.Helper.cs


return isClicked;
}
public static void OpenSceneSafe(GameSceneSO gameSceneSO)
{
if (EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo())
{
EditorSceneManager.OpenScene(AssetDatabase.GetAssetPath(gameSceneSO.sceneReference.editorAsset));
}
}
public static Color GetDefaultColor(GameSceneSO gameScene)
{

51
UOP1_Project/Assets/Scripts/Editor/SceneSelector/SceneSelector.cs


private List<Item> items => _storage.items;
private Dictionary<string, Item> itemsMap => _storage.itemsMap;
private GameSceneSO persistentManagerSceneSO, gameplaySceneSO;
[MenuItem("ChopChop/Scene Selector")]
private static void Open()
{

private void DrawWindow()
{
if(GUILayout.Button("Refresh scenes"))
{
//Forcing deletion of the storage, which will search the project and populate the scene list again
_storage = new Storage();
EditorPrefs.SetString(kPreferencesKey, "");
OnEnable();
}
using (var scrollScope = new EditorGUILayout.ScrollViewScope(_windowScrollPosition))
{
GUILayout.Space(4.0f);

if (GUILayout.Button("Reset list"))
{
//Force deletion of the storage
_storage = new Storage();
EditorPrefs.SetString(kPreferencesKey, "");
OnEnable(); //search the project and populate the scene list again
}
}
private void DrawItems()

{
if (GUILayout.Button(gameSceneSO.name, _styles.item))
{
OpenSceneSafe(gameSceneSO);
Helper.OpenSceneSafe(gameSceneSO);
}
var colorMarkerRect = GUILayoutUtility.GetLastRect();

guid = guid,
color = Helper.GetDefaultColor(gameSceneSO)
};
switch (item.gameSceneSO.sceneType)
{
case SceneType.PersistentManagers:
persistentManagerSceneSO = item.gameSceneSO;
break;
case SceneType.Gameplay:
gameplaySceneSO = item.gameSceneSO;
break;
}
items.Add(item);
itemsMap.Add(guid, item);

void IHasCustomMenu.AddItemsToMenu(GenericMenu menu)
{
menu.AddItem(kOpenPreferencesItemContent, false, OpenPreferences);
}
private void OpenSceneSafe(GameSceneSO gameSceneSO)
{
if (EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo())
{
EditorSceneManager.OpenScene(AssetDatabase.GetAssetPath(gameSceneSO.sceneReference.editorAsset));
//Check if it's a Location or Menu scene, load additional managers
if (gameSceneSO.sceneType == SceneType.Location)
{
EditorSceneManager.OpenScene(AssetDatabase.GetAssetPath(persistentManagerSceneSO.sceneReference.editorAsset), OpenSceneMode.Additive);
EditorSceneManager.OpenScene(AssetDatabase.GetAssetPath(gameplaySceneSO.sceneReference.editorAsset), OpenSceneMode.Additive);
}
else if (gameSceneSO.sceneType == SceneType.Menu)
{
EditorSceneManager.OpenScene(AssetDatabase.GetAssetPath(persistentManagerSceneSO.sceneReference.editorAsset), OpenSceneMode.Additive);
}
}
}
}

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


using System.Collections;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.AddressableAssets;
using System;
using UnityEngine.SceneManagement;
/// <summary>
/// This class is responsible for starting the game by loading the persistent managers scene

[Header("Loading settings")]
[SerializeField] private GameSceneSO[] _menuToLoad = default;
[SerializeField] private bool _showLoadScreen = default;
[Header("Broadcasting on")]
[SerializeField] private AssetReference _menuLoadChannel = default;

private void LoadMainMenu(AsyncOperationHandle<LoadEventChannelSO> obj)
{
LoadEventChannelSO loadEventChannelSO = (LoadEventChannelSO)_menuLoadChannel.Asset;
loadEventChannelSO.RaiseEvent(_menuToLoad, _showLoadScreen);
loadEventChannelSO.RaiseEvent(_menuToLoad);
SceneManager.UnloadSceneAsync(0); //Initialization is the only scene in BuildSettings, thus it has index 0
}

3
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
[Header("Broadcasting on")]
[SerializeField] private BoolEventChannelSO _toggleLoadingScreen = default;

52
UOP1_Project/Assets/Prefabs/Gameplay/EditorInitializer.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: EditorInitializer
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:
_thisSceneSO: {fileID: 0}
_persistentManagersSO: {fileID: 11400000, guid: c2119785ce96367428081d6eee0d932b,
type: 2}
_loadSceneEventChannel:
m_AssetGUID: 00e3063edc5902e40832ea618644c597
m_SubObjectName:
m_SubObjectType:

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


using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.ResourceManagement.AsyncOperations;
using UnityEngine.ResourceManagement.ResourceProviders;
using UnityEngine.SceneManagement;
/// <summary>
/// Allows a "cold start" in the editor, when pressing Play and not passing from the Initialisation scene.
/// </summary>
public class EditorColdStartup : MonoBehaviour
{
#if UNITY_EDITOR
[SerializeField] private GameSceneSO _thisSceneSO = default;
[SerializeField] private GameSceneSO _persistentManagersSO = default;
[SerializeField] private AssetReference _loadSceneEventChannel = default;
private void Start()
{
if (!SceneManager.GetSceneByName(_persistentManagersSO.sceneReference.editorAsset.name).isLoaded)
{
_persistentManagersSO.sceneReference.LoadSceneAsync(LoadSceneMode.Additive, true).Completed += LoadEventChannel;
}
}
private void LoadEventChannel(AsyncOperationHandle<SceneInstance> obj)
{
_loadSceneEventChannel.LoadAssetAsync<LoadEventChannelSO>().Completed += ReloadScene;
}
private void ReloadScene(AsyncOperationHandle<LoadEventChannelSO> obj)
{
LoadEventChannelSO loadEventChannelSO = (LoadEventChannelSO)_loadSceneEventChannel.Asset;
loadEventChannelSO.RaiseEvent(new GameSceneSO[] { _thisSceneSO });
SceneManager.UnloadSceneAsync(_thisSceneSO.sceneReference.editorAsset.name);
}
#endif
}

17
UOP1_Project/Assets/Scripts/SceneManagement/EditorColdStartup.cs.meta


fileFormatVersion: 2
guid: ca77942077a1ca846af4cc29b07958a8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences:
- _onSceneReady: {fileID: 11400000, guid: b729e40fc41dd8b4ea7aaf5c857f7186, type: 2}
- _thisSceneSO: {instanceID: 0}
- _persistentManagersSO: {fileID: 11400000, guid: c2119785ce96367428081d6eee0d932b,
type: 2}
- _loadSceneEventChannel: {fileID: 11400000, guid: 00e3063edc5902e40832ea618644c597,
type: 2}
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

7
UOP1_Project/Assets/Prefabs/Gameplay/MenuEditorInitializer.prefab.meta


fileFormatVersion: 2
guid: 0fa3e82c4006e714e8023cbf85cc999e
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

51
UOP1_Project/Assets/Prefabs/Gameplay/MenuEditorInitializer.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}
m_Layer: 0
m_Name: MenuEditorInitializer
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}
targetFramerate: 0
_isEditorInitializerMode: 0
_OnEditorInitializer: {fileID: 11400000, guid: 13c350be03ed8f54cbc7630aa33b3d7b,
type: 2}

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}

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


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
/// It takes care of telling the SpawnSystem that the scene is ready since we pressed play from it
/// and it is therefore already loaded
/// </summary>
public class SceneReadyBroadcaster : MonoBehaviour
{
[SerializeField] private VoidEventChannelSO _onSceneReady = default;
#if UNITY_EDITOR
[Header("Editor cold-startup settings")]
[SerializeField] private GameSceneSO _thisSceneSO = default;
[SerializeField] private GameSceneSO _persistentManagersScene = default;
[SerializeField] private LoadEventChannelSO _loadSceneEventChannel = default;
#endif
private void Start()
{
#if UNITY_EDITOR
_persistentManagersScene.sceneReference.LoadSceneAsync(LoadSceneMode.Additive, true).Completed += ReloadScene;
#endif
_onSceneReady.RaiseEvent();
}
private void ReloadScene(AsyncOperationHandle<SceneInstance> obj)
{
_loadSceneEventChannel.RaiseEvent(new GameSceneSO[] { _thisSceneSO });
SceneManager.UnloadSceneAsync(_thisSceneSO.sceneReference.editorAsset.name);
}
}

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


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

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

正在加载...
取消
保存