public IEnumerator LoadBackImage(string path) { defaultBackground.SetActive(false); if (Game.Packet.loadFromResources) { imageFrame.texture = Resources.Load <Texture2D>(path); imageFrame.gameObject.SetActive(true); loaded = true; } else { var request = UnityWebRequestTexture.GetTexture(path); yield return(request.SendWebRequest()); if (request.isNetworkError || request.isHttpError) { TSystemStatic.LogWarning("Error occured while loading background image."); } else { imageFrame.texture = ((DownloadHandlerTexture)request.downloadHandler).texture; imageFrame.gameObject.SetActive(true); loaded = true; } } }
public IEnumerator LoadMusic(string file, AudioType type) { loaded = false; if (Game.Packet.loadFromResources) { GetComponent <AudioSource>().clip = Resources.Load <AudioClip>(file); GetComponent <AudioSource>().volume = TSystemConfig.Now.musicVolume; loaded = true; } else { var request = UnityWebRequestMultimedia.GetAudioClip(file, type); yield return(request.SendWebRequest()); if (request.isNetworkError || request.isHttpError) { TSystemStatic.LogWarning("Error occured while loading music."); } else { GetComponent <AudioSource>().clip = ((DownloadHandlerAudioClip)request.downloadHandler).audioClip; GetComponent <AudioSource>().volume = TSystemConfig.Now.musicVolume; loaded = true; } } }
protected virtual IEnumerator Start() { Mode.SetArguments(); // Line construction for (int i = 0; i < Mode.lineSet.Length; i++) { var newPanel = Instantiate(linePanelTemplate); newPanel.GetComponent <RectTransform>().SetParent(lineParent); newPanel.GetComponent <RectTransform>().localScale = Vector3.one; newPanel.GetComponent <LinePanel>().Set(i); linePanels.Add(newPanel.GetComponent <LinePanel>()); newPanel.SetActive(true); if (i != 0) { newPanel.GetComponent <LinePanel>().fullBody.alpha = 0; } } // Beatmap Loading bool parseSucceed = false; maxReachTime = 0; switch (Packet.beatmap.type) { case BeatmapType.TWx: beatmapParser.ParseStructuredBeatmap(Packet.beatmap.path, Packet.beatmap.type, out parseSucceed); break; case BeatmapType.Deleste: beatmapParser.ParseDeleste(Packet.beatmap.path, out parseSucceed); break; case BeatmapType.SSTrain: beatmapParser.ParseStructuredBeatmap(Packet.beatmap.path, Packet.beatmap.type, out parseSucceed); break; } if (!parseSucceed) { TSystemStatic.LogWarning("Failed to parse beatmap. Game will NOT be played."); yield break; } CreateNote(new NoteData(systemNoteIdx--, 0, maxReachTime + 1, 1, 0, 0, NoteType.Ender, FlickType.NotFlick, Color.clear, new List <int>())); ChangeLine(0); AfterNoteLoading(); // Audio Loading if (!Packet.noMusic) { yield return(musicPlayer.LoadMusic(Packet.musicPath, Packet.musicType)); if (!musicPlayer.loaded) { TSystemStatic.LogWarning("Failed to load music. Game will be played without music."); } } // BGA/Image Loading if (!Packet.noBGA) { if (Packet.bgaPath != "") { backPlayer.LoadBGA(Packet.bgaPath); yield return(new WaitUntil(() => backPlayer.loaded || backPlayer.hasBgaError)); if (backPlayer.hasBgaError) { TSystemStatic.LogWarning("Failed to load BGA. Game will be played without BGA."); } } else if (Packet.backImagePath != "") { yield return(backPlayer.LoadBackImage(Packet.backImagePath)); if (!backPlayer.loaded) { TSystemStatic.LogWarning("Failed to load background image. Game will be played without background image."); } } } // Game values initializing //input.Initialize(); noteInput.Initialize(); Screen.sleepTimeout = SleepTimeout.NeverSleep; ReadyToPlay = true; }