fixed ci issue

This commit is contained in:
cyndrdev 2021-02-12 14:12:26 +00:00
parent 95f04ad618
commit 7a25b61f90
4 changed files with 819 additions and 320 deletions

8
game/Assets/Prefabs.meta Normal file
View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: f40cf77e2ef30fe4f8a89d5e5d5ee51e
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,487 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &1865034783
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1865034784}
- component: {fileID: 1865034787}
- component: {fileID: 1865034786}
- component: {fileID: 1865034785}
m_Layer: 0
m_Name: Cube
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1865034784
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1865034783}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0.5, z: 0.6}
m_LocalScale: {x: 0.1, y: 0.1, z: 0.1}
m_Children: []
m_Father: {fileID: 7846295001490405682}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!33 &1865034787
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1865034783}
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
--- !u!23 &1865034786
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1865034783}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RayTraceProcedural: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: 1b0f58118cf7a5a4e85fda00fe3de44b, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}
--- !u!65 &1865034785
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1865034783}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Size: {x: 1, y: 1, z: 1}
m_Center: {x: 0, y: 0, z: 0}
--- !u!1 &7846295001045979005
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 7846295001045979004}
- component: {fileID: 7846295001045979006}
- component: {fileID: 7846295001045978993}
- component: {fileID: 7846295001045978992}
- component: {fileID: 7846295000056357947}
m_Layer: 0
m_Name: Player
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &7846295001045979004
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7846295001045979005}
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: 7846295001490405682}
- {fileID: 7846295001499866554}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &7846295001045979006
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7846295001045979005}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: a734b8e2d64ba604795fd5cef5d741f4, type: 3}
m_Name:
m_EditorClassIdentifier:
_movementSettings: {fileID: 11400000, guid: 0c168708f93291545b51df2eec8f4ac3, type: 2}
_inputHandler: {fileID: 7846295001045978992}
_controller: {fileID: 7846295000056357947}
_graphics: {fileID: 7846295001490405682}
--- !u!114 &7846295001045978993
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7846295001045979005}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 62899f850307741f2a39c98a8b639597, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Actions: {fileID: -944628639613478452, guid: d4d9eb5db7beac84ca3cb36cfc09cd0a, type: 3}
m_NotificationBehavior: 2
m_UIInputModule: {fileID: 0}
m_DeviceLostEvent:
m_PersistentCalls:
m_Calls: []
m_DeviceRegainedEvent:
m_PersistentCalls:
m_Calls: []
m_ControlsChangedEvent:
m_PersistentCalls:
m_Calls: []
m_ActionEvents:
- m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 7846295001045978992}
m_TargetAssemblyTypeName: PlayerInputHandler, Assembly-CSharp
m_MethodName: Move
m_Mode: 0
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
m_ActionId: 5c440996-60ec-4084-9223-75d39638108a
m_ActionName: CoreMap/Move[/Keyboard/w,/Keyboard/s,/Keyboard/a,/Keyboard/d,/XInputControllerWindows/leftStick]
- m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 7846295001045978992}
m_TargetAssemblyTypeName: PlayerInputHandler, Assembly-CSharp
m_MethodName: Look
m_Mode: 0
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
m_ActionId: d271942b-8516-4550-88ae-552350feb4b1
m_ActionName: CoreMap/Look[/Mouse/delta,/XInputControllerWindows/rightStick]
- m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 7846295001045978992}
m_TargetAssemblyTypeName: PlayerInputHandler, Assembly-CSharp
m_MethodName: Jump
m_Mode: 0
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
m_ActionId: da936947-fcfa-4872-a4e3-15763afe56b6
m_ActionName: CoreMap/Jump[/Keyboard/space,/XInputControllerWindows/buttonSouth]
- m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 7846295001045978992}
m_TargetAssemblyTypeName: PlayerInputHandler, Assembly-CSharp
m_MethodName: Use
m_Mode: 0
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
m_ActionId: 2bbc2e93-6016-4544-8399-0c4ee222850c
m_ActionName: CoreMap/Use[/Keyboard/e,/XInputControllerWindows/buttonWest]
m_NeverAutoSwitchControlSchemes: 1
m_DefaultControlScheme: Gamepad
m_DefaultActionMap: CoreMap
m_SplitScreenIndex: -1
m_Camera: {fileID: 7846295001499866555}
--- !u!114 &7846295001045978992
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7846295001045979005}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e12816fc78a8ca3429be019aa4e51fdd, type: 3}
m_Name:
m_EditorClassIdentifier:
_inputSettings: {fileID: 11400000, guid: 09b165d6ce14f86459be7213da9688a7, type: 2}
--- !u!143 &7846295000056357947
CharacterController:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7846295001045979005}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Height: 2
m_Radius: 0.5
m_SlopeLimit: 45
m_StepOffset: 0.3
m_SkinWidth: 0.01
m_MinMoveDistance: 0.001
m_Center: {x: 0, y: 1, z: 0}
--- !u!1 &7846295001490405694
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 7846295001490405682}
- component: {fileID: 7846295001490405683}
- component: {fileID: 7846295001490405680}
m_Layer: 0
m_Name: Graphics
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &7846295001490405682
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7846295001490405694}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 1, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 1865034784}
m_Father: {fileID: 7846295001045979004}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!33 &7846295001490405683
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7846295001490405694}
m_Mesh: {fileID: 10208, guid: 0000000000000000e000000000000000, type: 0}
--- !u!23 &7846295001490405680
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7846295001490405694}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RayTraceProcedural: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: 1b0f58118cf7a5a4e85fda00fe3de44b, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}
--- !u!1 &7846295001499866553
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 7846295001499866554}
- component: {fileID: 7846295001499866555}
- component: {fileID: 7846295001499866552}
- component: {fileID: 7846295001499866557}
- component: {fileID: 7846295001499866556}
m_Layer: 0
m_Name: PlayerCamera
m_TagString: MainCamera
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &7846295001499866554
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7846295001499866553}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 1, z: -10}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 7846295001045979004}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!20 &7846295001499866555
Camera:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7846295001499866553}
m_Enabled: 1
serializedVersion: 2
m_ClearFlags: 1
m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
m_projectionMatrixMode: 1
m_GateFitMode: 2
m_FOVAxisMode: 0
m_SensorSize: {x: 36, y: 24}
m_LensShift: {x: 0, y: 0}
m_FocalLength: 50
m_NormalizedViewPortRect:
serializedVersion: 2
x: 0
y: 0
width: 1
height: 1
near clip plane: 0.3
far clip plane: 1000
field of view: 65
orthographic: 0
orthographic size: 5
m_Depth: -1
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_RenderingPath: -1
m_TargetTexture: {fileID: 0}
m_TargetDisplay: 0
m_TargetEye: 3
m_HDR: 1
m_AllowMSAA: 1
m_AllowDynamicResolution: 0
m_ForceIntoRT: 0
m_OcclusionCulling: 1
m_StereoConvergence: 10
m_StereoSeparation: 0.022
--- !u!81 &7846295001499866552
AudioListener:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7846295001499866553}
m_Enabled: 1
--- !u!114 &7846295001499866557
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7846295001499866553}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: a79441f348de89743a2939f4d699eac1, type: 3}
m_Name:
m_EditorClassIdentifier:
m_RenderShadows: 1
m_RequiresDepthTextureOption: 2
m_RequiresOpaqueTextureOption: 2
m_CameraType: 0
m_Cameras: []
m_RendererIndex: 0
m_VolumeLayerMask:
serializedVersion: 2
m_Bits: 1
m_VolumeTrigger: {fileID: 0}
m_RenderPostProcessing: 1
m_Antialiasing: 0
m_AntialiasingQuality: 2
m_StopNaN: 0
m_Dithering: 0
m_ClearDepth: 1
m_AllowXRRendering: 1
m_RequiresDepthTexture: 0
m_RequiresColorTexture: 0
m_Version: 2
--- !u!114 &7846295001499866556
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7846295001499866553}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 805caadbe4df94a40bf7ddb70bea02f6, type: 3}
m_Name:
m_EditorClassIdentifier:
_settings: {fileID: 11400000, guid: 995f378ab762cd344b7a6d108f049191, type: 2}
_inputHandler: {fileID: 7846295001045978992}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: ed6e7ba262c00374d9ed95757ea54c05
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,321 +1,318 @@
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data; using System.Text;
using System.Runtime.InteropServices; using NaughtyAttributes;
using System.Text; using UnityEngine;
using NaughtyAttributes; using UnityEngine.SceneManagement;
using UnityEditor.Experimental.Rendering; using UnityEngine.UI;
using UnityEngine; using TMPro;
using UnityEngine.SceneManagement;
using UnityEngine.UI; enum LoadState
using TMPro; {
Idle,
enum LoadState FadeOut,
{ UnityUnload,
Idle, Cleanup,
FadeOut, UnityLoad,
UnityUnload, SceneSetup,
Cleanup, Sync,
UnityLoad, FadeIn,
SceneSetup,
Sync, COUNT
FadeIn, }
COUNT public class Bootstrap : MonoBehaviour
} {
[Header( "Debug" )]
public class Bootstrap : MonoBehaviour [SerializeField]
{ private bool _debugMode;
[Header( "Debug" )]
[SerializeField] [Header( "Config" )]
private bool _debugMode; [SerializeField] [Expandable]
private BootstrapConfig _config;
[Header( "Config" )]
[SerializeField] [Expandable] private static Bootstrap _instance;
private BootstrapConfig _config;
private LoadState _loadState;
private static Bootstrap _instance; private Coroutine _currentSceneLoad;
private SceneType _activeSceneType;
private LoadState _loadState;
private Coroutine _currentSceneLoad; private SceneLoader _activeScene;
private SceneType _activeSceneType; private string _activeSceneName;
private SceneLoader _activeScene; [Header( "References" )]
private string _activeSceneName; [SerializeField]
private Image _fader;
[Header( "References" )]
[SerializeField] [SerializeField]
private Image _fader; private TMP_Text _debugDisplay;
[SerializeField] //private LevelDescriptor _activeLevelDescriptor;
private TMP_Text _debugDisplay;
private List<LevelDescriptor> _loadedLevels = new List<LevelDescriptor>();
//private LevelDescriptor _activeLevelDescriptor;
private Queue<LevelDescriptor> _toLoadLevels = new Queue<LevelDescriptor>();
private List<LevelDescriptor> _loadedLevels = new List<LevelDescriptor>(); private AsyncOperation _levelLoadAsync = null;
private Queue<LevelDescriptor> _toLoadLevels = new Queue<LevelDescriptor>(); private Queue<LevelDescriptor> _toUnloadLevels = new Queue<LevelDescriptor>();
private AsyncOperation _levelLoadAsync = null; private AsyncOperation _levelUnloadAsync = null;
private Queue<LevelDescriptor> _toUnloadLevels = new Queue<LevelDescriptor>(); public bool IsLoading => _loadState != LoadState.Idle;
private AsyncOperation _levelUnloadAsync = null;
private void QueryLoadState()
public bool IsLoading => _loadState != LoadState.Idle; {
if ( _activeScene != null && _activeScene.ToLoad != SceneType.None )
private void QueryLoadState() {
{ LoadScene( _activeScene.ToLoad );
if ( _activeScene != null && _activeScene.ToLoad != SceneType.None ) }
{ }
LoadScene( _activeScene.ToLoad );
} private void Awake()
} {
_instance = this;
private void Awake()
{ if ( _debugMode )
_instance = this; {
StartCoroutine( DebugCR() );
if ( _debugMode ) }
{ }
StartCoroutine( DebugCR() );
} void Start()
} {
LoadScene( SceneType.BootSequence );
void Start() }
{
LoadScene( SceneType.BootSequence ); public static void LoadScene( SceneType scene )
} {
if ( _instance.IsLoading )
public static void LoadScene( SceneType scene ) {
{ Debug.LogError( "[Bootstrap]: couldn't load scene: another load operation already active." );
if ( _instance.IsLoading ) return;
{ }
Debug.LogError( "[Bootstrap]: couldn't load scene: another load operation already active." );
return; _instance._currentSceneLoad = _instance.StartCoroutine( _instance.LoadSceneCR( scene ) );
} }
_instance._currentSceneLoad = _instance.StartCoroutine( _instance.LoadSceneCR( scene ) ); public static void LoadLevel( LevelDescriptor descriptor )
} {
_instance._toLoadLevels.Enqueue( descriptor );
public static void LoadLevel( LevelDescriptor descriptor ) }
{
_instance._toLoadLevels.Enqueue( descriptor ); private IEnumerator DebugCR()
} {
LoadState loadState = LoadState.COUNT;
private IEnumerator DebugCR() StringBuilder sb = new StringBuilder();
{
LoadState loadState = LoadState.COUNT; while ( true )
StringBuilder sb = new StringBuilder(); {
if ( _loadState != loadState )
while ( true ) {
{ loadState = _loadState;
if ( _loadState != loadState ) sb.Clear();
{
loadState = _loadState; sb.Append( "LoadState::" );
sb.Clear(); sb.AppendLine( _loadState.ToString() );
sb.Append( "LoadState::" ); if ( _activeSceneName != null )
sb.AppendLine( _loadState.ToString() ); {
sb.AppendFormat( "S: {0} ({1})", _activeSceneType, _activeSceneName );
if ( _activeSceneName != null ) }
{ else
sb.AppendFormat( "S: {0} ({1})", _activeSceneType, _activeSceneName ); {
} sb.AppendFormat( "S: [none]" );
else }
{
sb.AppendFormat( "S: [none]" ); sb.Append( "\n" );
}
if ( (_loadedLevels?.Count ?? 0) > 0 )
sb.Append( "\n" ); {
sb.Append( "L: " );
if ( (_loadedLevels?.Count ?? 0) > 0 ) for ( int i = 0; i < _loadedLevels.Count; ++i )
{ {
sb.Append( "L: " ); sb.Append( _loadedLevels[ i ].LevelScene );
for ( int i = 0; i < _loadedLevels.Count; ++i ) if ( i != _loadedLevels.Count - 1 )
{ {
sb.Append( _loadedLevels[ i ].LevelScene ); sb.Append( ", " );
if ( i != _loadedLevels.Count - 1 ) }
{ }
sb.Append( ", " ); }
} else
} {
} sb.AppendFormat( "L: [none]" );
else }
{
sb.AppendFormat( "L: [none]" ); sb.Append( "\n" );
} sb.AppendFormat( "Load: {0} ({1} queued)\n", _levelLoadAsync?.isDone ?? true ? "idle" : "busy" , _toLoadLevels.Count );
sb.AppendFormat( "Unload: {0} ({1} queued)\n", _levelUnloadAsync?.isDone ?? true ? "idle" : "busy" , _toUnloadLevels.Count );
sb.Append( "\n" );
sb.AppendFormat( "Load: {0} ({1} queued)\n", _levelLoadAsync?.isDone ?? true ? "idle" : "busy" , _toLoadLevels.Count ); _debugDisplay.SetText( sb.ToString() );
sb.AppendFormat( "Unload: {0} ({1} queued)\n", _levelUnloadAsync?.isDone ?? true ? "idle" : "busy" , _toUnloadLevels.Count ); }
_debugDisplay.SetText( sb.ToString() ); yield return null;
} }
}
yield return null;
} private bool ProcessLevelUnloads()
} {
if (_levelUnloadAsync?.isDone ?? true)
private bool ProcessLevelUnloads() {
{ while (true)
if (_levelUnloadAsync?.isDone ?? true) {
{ if ( _toUnloadLevels.Count == 0 )
while (true) {
{ break;
if ( _toUnloadLevels.Count == 0 ) }
{
break; var target = _toUnloadLevels.Dequeue();
} if ( _loadedLevels.Contains( target ) == false )
{
var target = _toUnloadLevels.Dequeue(); continue;
if ( _loadedLevels.Contains( target ) == false ) }
{
continue; _levelUnloadAsync = SceneManager.UnloadSceneAsync( target.LevelScene );
} _loadedLevels.Remove( target );
return false;
_levelUnloadAsync = SceneManager.UnloadSceneAsync( target.LevelScene ); }
_loadedLevels.Remove( target ); }
return false;
} return (_levelUnloadAsync?.isDone ?? true) && _toUnloadLevels.Count == 0;
} }
return (_levelUnloadAsync?.isDone ?? true) && _toUnloadLevels.Count == 0; private bool ProcessLevelLoads()
} {
if (_levelLoadAsync?.isDone ?? true)
private bool ProcessLevelLoads() {
{ while (true)
if (_levelLoadAsync?.isDone ?? true) {
{ if ( _toLoadLevels.Count == 0 )
while (true) {
{ break;
if ( _toLoadLevels.Count == 0 ) }
{
break; var target = _toLoadLevels.Dequeue();
} if ( _loadedLevels.Contains( target ) )
{
var target = _toLoadLevels.Dequeue(); continue;
if ( _loadedLevels.Contains( target ) ) }
{
continue; _levelLoadAsync = SceneManager.LoadSceneAsync( target.LevelScene, LoadSceneMode.Additive );
} _loadedLevels.Add( target );
return false;
_levelLoadAsync = SceneManager.LoadSceneAsync( target.LevelScene, LoadSceneMode.Additive ); }
_loadedLevels.Add( target ); }
return false;
} return (_levelLoadAsync?.isDone ?? true) && _toLoadLevels.Count == 0;
} }
return (_levelLoadAsync?.isDone ?? true) && _toLoadLevels.Count == 0; private IEnumerator LoadSceneCR( SceneType scene )
} {
AsyncOperation asyncOp;
private IEnumerator LoadSceneCR( SceneType scene )
{ // fade out
AsyncOperation asyncOp; _loadState = LoadState.FadeOut;
_fader.CrossFadeAlpha( 1f, _config.TransitionDuration, true );
// fade out yield return new WaitForSecondsRealtime( _config.TransitionDuration );
_loadState = LoadState.FadeOut;
_fader.CrossFadeAlpha( 1f, _config.TransitionDuration, true ); // unload unity's scenes
yield return new WaitForSecondsRealtime( _config.TransitionDuration ); _loadState = LoadState.UnityUnload;
// unload unity's scenes if ( _activeSceneName != null )
_loadState = LoadState.UnityUnload; {
// unload main scene
if ( _activeSceneName != null ) asyncOp = SceneManager.UnloadSceneAsync( _activeSceneName );
{
// unload main scene while ( asyncOp.isDone == false )
asyncOp = SceneManager.UnloadSceneAsync( _activeSceneName ); yield return null;
while ( asyncOp.isDone == false ) _activeScene = null;
yield return null; _activeSceneName = null;
}
_activeScene = null;
_activeSceneName = null; // cleanup
} _loadState = LoadState.Cleanup;
// cleanup if ( scene == SceneType.Gameplay )
_loadState = LoadState.Cleanup; {
_toUnloadLevels.Clear();
if ( scene == SceneType.Gameplay ) _toLoadLevels.Clear();
{ _loadedLevels.Clear();
_toUnloadLevels.Clear(); _toLoadLevels.Enqueue( _config.StartLevel );
_toLoadLevels.Clear(); }
_loadedLevels.Clear(); else
_toLoadLevels.Enqueue( _config.StartLevel ); {
} _toLoadLevels.Clear();
else
{ for ( int i = 0; i < _loadedLevels.Count; ++i )
_toLoadLevels.Clear(); {
if ( _toUnloadLevels.Contains( _loadedLevels[ i ] ) == false )
for ( int i = 0; i < _loadedLevels.Count; ++i ) {
{ _toUnloadLevels.Enqueue( _loadedLevels[ i ] );
if ( _toUnloadLevels.Contains( _loadedLevels[ i ] ) == false ) }
{ }
_toUnloadLevels.Enqueue( _loadedLevels[ i ] ); }
}
} // 6 collections, as that is the deepest unity hierarchies go.
} for ( int i = 0; i < 6; ++i )
{
// 6 collections, as that is the deepest unity hierarchies go. GC.Collect();
for ( int i = 0; i < 6; ++i ) yield return null;
{ }
GC.Collect();
yield return null; // unity loading
} _loadState = LoadState.UnityLoad;
_activeSceneType = scene;
// unity loading _activeSceneName = _config.GetScene( scene );
_loadState = LoadState.UnityLoad;
_activeSceneType = scene; asyncOp = SceneManager.LoadSceneAsync( _activeSceneName, LoadSceneMode.Additive );
_activeSceneName = _config.GetScene( scene );
while ( asyncOp.isDone == false )
asyncOp = SceneManager.LoadSceneAsync( _activeSceneName, LoadSceneMode.Additive ); yield return null;
while ( asyncOp.isDone == false ) // setup
yield return null; _loadState = LoadState.SceneSetup;
// setup _activeScene = FindObjectOfType<SceneLoader>();
_loadState = LoadState.SceneSetup;
while ( _activeScene.LoadComplete == false )
_activeScene = FindObjectOfType<SceneLoader>(); yield return null;
while ( _activeScene.LoadComplete == false ) // sync
yield return null; _loadState = LoadState.Sync;
while ( ProcessLevelUnloads() == false )
// sync {
_loadState = LoadState.Sync; yield return null;
while ( ProcessLevelUnloads() == false ) }
{
yield return null; while ( ProcessLevelLoads() == false )
} {
yield return null;
while ( ProcessLevelLoads() == false ) }
{
yield return null; // fade in
} _loadState = LoadState.FadeIn;
_fader.CrossFadeAlpha( 0f, _config.TransitionDuration, true );
// fade in yield return new WaitForSecondsRealtime( _config.TransitionDuration );
_loadState = LoadState.FadeIn;
_fader.CrossFadeAlpha( 0f, _config.TransitionDuration, true ); yield return null;
yield return new WaitForSecondsRealtime( _config.TransitionDuration ); _loadState = LoadState.Idle;
_currentSceneLoad = null;
yield return null; }
_loadState = LoadState.Idle;
_currentSceneLoad = null;
} private void Update()
{
if ( !IsLoading )
private void Update() {
{ QueryLoadState();
if ( !IsLoading )
{ if ( _activeSceneType == SceneType.Gameplay )
QueryLoadState(); {
if ( ProcessLevelUnloads() )
if ( _activeSceneType == SceneType.Gameplay ) {
{ ProcessLevelLoads();
if ( ProcessLevelUnloads() ) }
{ }
ProcessLevelLoads(); }
} }
}
}
}
} }