internal void NotFound(string name) { if (name != null) { if (reportAssets) { if (loadedAsset != null) { AssetReport.instance.NotFound(name, loadedAsset); } else { AssetReport.instance.NotFound(name); } } if (failedAssets.Add(name)) { Util.DebugPrint("Asset not found:", name); int j = name.IndexOf('.'); if (j >= 0 && j < name.Length - 1) { name = name.Substring(j + 1); } name = AssetName(name); LoadingManager.instance.m_loadingProfilerCustomAsset.BeginLoading(name); Profiling.CustomAssetNotFound(name); LoadingManager.instance.m_loadingProfilerCustomAsset.EndLoading(); DualProfilerSource profiler = LoadingScreen.instance.DualSource; profiler?.SomeNotFound(); } } }
internal void NotFound(string fullName) { if (fullName != null) { if (reportAssets) { if (!string.IsNullOrEmpty(Current)) { AssetReport.instance.NotFound(fullName, Current); } else { AssetReport.instance.NotFound(fullName); } } if (failedAssets.Add(fullName)) { Util.DebugPrint("Asset not found:", fullName); string name = ShorterAssetName(fullName); LoadingManager.instance.m_loadingProfilerCustomAsset.BeginLoading(name); Profiling.CustomAssetNotFound(name); LoadingManager.instance.m_loadingProfilerCustomAsset.EndLoading(); DualProfilerSource profiler = LoadingScreen.instance.DualSource; profiler?.SomeNotFound(); } } }
public Coroutine LoadLevel(Package.Asset asset, string playerScene, string uiScene, SimulationMetaData ngs, bool forceEnvironmentReload = false) { LoadingManager lm = Singleton <LoadingManager> .instance; bool activated = ngs.m_updateMode == SimulationManager.UpdateMode.LoadGame || ngs.m_updateMode == SimulationManager.UpdateMode.NewGameFromMap || ngs.m_updateMode == SimulationManager.UpdateMode.NewGameFromScenario || Input.GetKey(KeyCode.LeftControl); instance.simulationFailed = instance.assetsStarted = instance.assetsFinished = false; if (!lm.m_currentlyLoading && !lm.m_applicationQuitting) { if (lm.m_LoadingWrapper != null) { lm.m_LoadingWrapper.OnLevelUnloading(); // OnLevelUnloading } if (activated) { Settings s = Settings.settings; Util.DebugPrint("Options: 121", s.loadEnabled, s.loadUsed, s.shareTextures, s.shareMaterials, s.shareMeshes, s.reportAssets, s.skipPrefabs); LoadingManager.instance.SetSceneProgress(0f); instance.cityName = asset?.name ?? "NewGame"; Profiling.Init(); CustomDeserializer.Create(); Fixes.Create().Deploy(); LoadingScreen.Create().Setup(); } lm.LoadingAnimationComponent.enabled = true; lm.m_currentlyLoading = true; lm.m_metaDataLoaded = false; lm.m_simulationDataLoaded = false; lm.m_loadingComplete = false; lm.m_renderDataReady = false; lm.m_essentialScenesLoaded = false; lm.m_brokenAssets = string.Empty; Util.Set(lm, "m_sceneProgress", 0f); Util.Set(lm, "m_simulationProgress", 0f); if (activated) { Profiling.Start(); } lm.m_loadingProfilerMain.Reset(); lm.m_loadingProfilerSimulation.Reset(); lm.m_loadingProfilerScenes.Reset(); //LoadingManager.instance.m_loadingProfilerCustomContent.Reset(); //LoadingManager.instance.m_loadingProfilerCustomAsset.Reset(); IEnumerator iter = activated ? instance.LoadLevelCoroutine(asset, playerScene, uiScene, ngs, forceEnvironmentReload) : (IEnumerator)Util.Invoke(lm, "LoadLevelCoroutine", asset, playerScene, uiScene, ngs, forceEnvironmentReload); return(lm.StartCoroutine(iter)); } return(null); }
// Loading complete. public IEnumerator LoadingComplete() { Util.DebugPrint("All completed at", Profiling.Millis); AssetLoader.instance.PrintMem(); Singleton <LoadingManager> .instance.LoadingAnimationComponent.enabled = false; AssetLoader.instance.Dispose(); Fixes.instance?.Dispose(); CustomDeserializer.instance?.Dispose(); Profiling.Stop(); yield break; }
public Coroutine LoadLevel(Package.Asset asset, string playerScene, string uiScene, SimulationMetaData ngs) { LoadingManager lm = Singleton <LoadingManager> .instance; instance.activated = ngs.m_updateMode == SimulationManager.UpdateMode.LoadGame || ngs.m_updateMode == SimulationManager.UpdateMode.NewGameFromMap || ngs.m_updateMode == SimulationManager.UpdateMode.NewGameFromScenario || Input.GetKey(KeyCode.LeftControl); instance.simulationFailed = false; if (!lm.m_currentlyLoading && !lm.m_applicationQuitting) { if (lm.m_LoadingWrapper != null) { lm.m_LoadingWrapper.OnLevelUnloading(); } if (instance.activated) { instance.cityName = asset?.name ?? "NewGame"; Profiling.Init(); new AssetLoader().Setup(); new LoadingScreen().Setup(); } lm.LoadingAnimationComponent.enabled = true; lm.m_currentlyLoading = true; lm.m_metaDataLoaded = false; lm.m_simulationDataLoaded = false; lm.m_loadingComplete = false; lm.m_renderDataReady = false; lm.m_essentialScenesLoaded = false; lm.m_brokenAssets = string.Empty; Util.Set(lm, "m_sceneProgress", 0f); Util.Set(lm, "m_simulationProgress", 0f); if (instance.activated) { Profiling.stopWatch.Start(); } lm.m_loadingProfilerMain.Reset(); lm.m_loadingProfilerSimulation.Reset(); lm.m_loadingProfilerScenes.Reset(); IEnumerator iter = instance.activated ? instance.LoadLevelCoroutine(asset, playerScene, uiScene, ngs) : (IEnumerator)Util.Invoke(lm, "LoadLevelCoroutine", asset, playerScene, uiScene, ngs); return(lm.StartCoroutine(iter)); } return(null); }
internal void SaveStats() { try { Util.DebugPrint("Saving stats to", filepath); w = new StreamWriter(filepath, append: true); H2("Loading stats"); H3("Performance"); Stat("Custom assets loaded", AssetLoader.instance.assetCount, "assets"); int dt = AssetLoader.instance.lastMillis - AssetLoader.instance.beginMillis; if (dt > 0) { Stat("Loading speed", (AssetLoader.instance.assetCount * 1000f / dt).ToString("F1"), "assets / second"); } Stat("Custom assets loading time", Profiling.TimeString(dt + 500), "minutes:seconds"); Stat("Total loading time", Profiling.TimeString(Profiling.Millis + 500), "minutes:seconds"); if (Application.platform == RuntimePlatform.WindowsPlayer || Application.platform == RuntimePlatform.WindowsEditor) { H3("Peak memory usage"); Stat("RAM", (MemoryAPI.wsMax / 1024f).ToString("F1"), "GB"); Stat("Virtual memory", (MemoryAPI.pfMax / 1024f).ToString("F1"), "GB"); } H3("Sharing of custom asset resources"); Stat("Textures", texturesShared, "times"); Stat("Materials", materialsShared, "times"); Stat("Meshes", meshesShared, "times"); H3("Skipped prefabs"); int[] counts = LevelLoader.instance.skipCounts; Stat("Building prefabs", counts[Matcher.BUILDINGS], string.Empty); Stat("Vehicle prefabs", counts[Matcher.VEHICLES], string.Empty); Stat("Prop prefabs", counts[Matcher.PROPS], string.Empty); w.WriteLine(@"</body></html>"); } catch (Exception e) { UnityEngine.Debug.LogException(e); } finally { w?.Dispose(); w = null; } }
internal void Duplicate(string fullName, Package package) { string path = package.packagePath ?? "Path unknown"; if (reportAssets) { AssetReport.instance.Duplicate(fullName, path); } Util.DebugPrint("Duplicate asset", fullName, "in", path); string name = ShorterAssetName(fullName); LoadingManager.instance.m_loadingProfilerCustomAsset.BeginLoading(name); Profiling.CustomAssetDuplicate(name); LoadingManager.instance.m_loadingProfilerCustomAsset.EndLoading(); DualProfilerSource profiler = LoadingScreen.instance.DualSource; profiler?.SomeDuplicate(); }
internal override void Dispose() { UIFontManager.callbackRequestCharacterInfo = (UIFontManager.CallbackRequestCharacterInfo)Delegate.Remove(UIFontManager.callbackRequestCharacterInfo, new UIFontManager.CallbackRequestCharacterInfo(instance.RequestCharacterInfo)); Font.textureRebuilt -= new Action <Font>(instance.FontTextureRebuilt); Revert(); base.Dispose(); if (imageMaterial != null) { UnityEngine.Object.Destroy(imageMaterial); } foreach (Text t in texts) { t.Dispose(); } if (textMaterial != null) { UnityEngine.Object.Destroy(textMaterial); } if (bgMesh != null) { UnityEngine.Object.Destroy(bgMesh); } if (bgMaterial != null) { UnityEngine.Object.Destroy(bgMaterial); } instance = null; imageMesh = null; imageMaterial = null; animationMesh = null; animationMaterial = null; barBGMaterial = null; barFGMaterial = null; textMaterial = null; bgMesh = null; bgMaterial = null; imageLoaded = animationLoaded = fontLoaded = bgLoaded = false; AssetLoader.instance?.Dispose(); Sharing.instance?.Dispose(); Profiling.Stop(); }
internal void AssetFailed(string fullName, Exception e) { if (fullName != null && failedAssets.Add(fullName)) { Util.DebugPrint("Asset failed:", fullName); if (reportAssets) { AssetReport.instance.AssetFailed(fullName); } Profiling.CustomAssetFailed(ShorterAssetName(fullName)); DualProfilerSource profiler = LoadingScreen.instance.DualSource; profiler?.SomeFailed(); } if (e != null) { UnityEngine.Debug.LogException(e); } }
internal void Failed(Package.Asset data, Exception e) { string name = data?.name; if (name != null && failedAssets.Add(data.fullName)) { Util.DebugPrint("Asset failed:", data.fullName); if (reportAssets) { AssetReport.instance.Failed(data.fullName); } Profiling.CustomAssetFailed(AssetName(name)); DualProfilerSource profiler = LoadingScreen.instance.DualSource; profiler?.SomeFailed(); } if (e != null) { UnityEngine.Debug.LogException(e); } }
protected internal override string CreateText() => Profiling.TimeString(Profiling.Millis);