public override void Activate(bool active, params object[] parameters) { base.Activate(active, parameters); if (SystemInfo.graphicsShaderLevel < 30) { Diagnostics.LogError("Insufficient hardware. UnityEngine.SystemInfo.graphicsShaderLevel = {0}. Should be higher or equal than {1}", new object[] { SystemInfo.graphicsShaderLevel, 30 }); } Amplitude.Unity.Audio.IAudioLayeredMusicService service = Services.GetService <Amplitude.Unity.Audio.IAudioLayeredMusicService>(); if (service != null) { service.StopAllMusics(); } if (active) { this.LoadScene(); } else { this.UnloadScene(); } }
private IEnumerator LoadSceneAsync(string levelName) { if (this.loadLevelAsyncOperation != null) { yield break; } Amplitude.Unity.Gui.IGuiService guiService = Services.GetService <Amplitude.Unity.Gui.IGuiService>(); LoadingScreen loadingScreen = guiService.GetGuiPanel <LoadingScreen>(); if (loadingScreen != null) { object dontDisplayAnyLoadingTip = new LoadingScreen.DontDisplayAnyLoadingTip(); loadingScreen.Show(new object[] { dontDisplayAnyLoadingTip }); } Diagnostics.Log("Loading the outgame view..."); Diagnostics.Progress.SetProgress(1f, "%GameClientStateLoadingOutgameView"); this.loadLevelAsyncOperation = SceneManager.LoadSceneAsync(levelName, LoadSceneMode.Additive); while (!this.loadLevelAsyncOperation.isDone) { yield return(null); } this.SceneObject = GameObject.Find("[OutGameView_Layout]"); if (this.SceneObject == null) { Diagnostics.LogError("Cannot locate the root object '{0}' after loading the scene '{1}'.", new object[] { "[OutGameView_Layout]", levelName }); } else { GameObject sceneObject = this.SceneObject; sceneObject.name += "(scene: additive, async)"; this.SceneObject.transform.parent = base.transform; this.SceneObject.transform.localPosition = Vector3.zero; this.SceneObject.transform.localRotation = Quaternion.identity; this.SceneObject.SetActive(true); } this.loadLevelAsyncOperation = null; Resources.UnloadUnusedAssets(); if (Amplitude.Unity.Framework.Application.Bootstrapper != null) { Amplitude.Unity.Framework.Application.Bootstrapper.gameObject.SetActive(false); } guiService.Hide(typeof(LoadingScreen)); if (this.Parameters.Length == 1) { Type typeOfPanelToShow = this.Parameters[0] as Type; Diagnostics.Assert(typeOfPanelToShow != null); guiService.Show(typeOfPanelToShow, new object[0]); } Amplitude.Unity.Audio.IAudioLayeredMusicService musicService = Services.GetService <Amplitude.Unity.Audio.IAudioLayeredMusicService>(); musicService.PlayLayeredMusic("OutGameMusic", OutGameView.OutGameMusicName, 1); yield break; }