public void SwitchLanguage(LanguageType type) { ZLog.Warning("LocalManager SwitchLanguage...from = " + language + " to " + type); if (language == type) return; language = type; TextAsset asset = null; if(type == LanguageType.Chinese){ asset = Resources.Load<TextAsset>("xml/chinese"); //LocalManager.currentFont = Font.CreateDynamicFontFromOSFont("Droid Sans Mono", 14); }else if(type == LanguageType.English){ asset = Resources.Load<TextAsset>("xml/english"); //LocalManager.currentFont = Font.CreateDynamicFontFromOSFont("Droid Sans Mono", 14); }else if(type == LanguageType.Japanese){ asset = Resources.Load<TextAsset>("xml/japanese"); proxy.Parse(asset.text); currentFont = Font.CreateDynamicFontFromOSFont("Noto Sans JP", 14); } else if (type == LanguageType.Korean) { asset = Resources.Load<TextAsset>("xml/korean"); } if (asset != null) { proxy.Parse(asset.text); NotifyManager.SendNotify(NotifyType.OnLaguageUpdate,null); } }
IEnumerator LoadMultyInspector(string identify, AudioLoad[] audios, bool loop, AudioType format) { int length = audios.Length; isLoading = true; AudioClip[] array = new AudioClip[length]; for (int i = 0; i < length; i++) { string uid = AlgorithmUtil.ToMD5(audios[i].path); AudioClip clip = GetClip(uid); if (clip == null) { using (var www = UnityWebRequestMultimedia.GetAudioClip("file://" + audios[i].path, format)) { yield return(www.SendWebRequest()); if (www.isNetworkError) { ZLog.Warning("load the music is empty!!!that path = " + www.error); NotifyManager.SendNotify(NotifyType.OnAudioLoadError, ""); yield break; } clip = DownloadHandlerAudioClip.GetContent(www); if (clip.length < 1) { ZLog.Warning("load the music is empty!!!that path = " + audios[i].path); NotifyManager.SendNotify(NotifyType.OnAudioLoadError, ""); yield break; } AudioInfo audioInfo = new AudioInfo { uid = uid, clip = clip }; clips.Add(audioInfo); array[i] = clip; } } else { array[i] = clip; yield return(null); } } for (int i = 0; i < length; i++) { ActiveMusic(array[i], audios[i].target, loop); } yield return(null); isLoading = false; NotifyManager.SendNotify(NotifyType.OnAudioPlay, identify); }
private void ReadFile(string uid, string path, GameObject target, bool loop) { byte[] data = File.ReadAllBytes(path); AudioBuffer buffer = new AudioBuffer { uid = uid, data = data, target = target, loop = loop }; NotifyManager.SendNotify(NotifyType.OnAudioRead, buffer); }
private IEnumerator LoadAndPlayDelay(string uid, string path, GameObject target, bool loop, bool isSound, AudioType format) { isLoading = true; ZLog.Log("audio manager try load data that path = " + path); using (var loader = UnityWebRequestMultimedia.GetAudioClip("file://" + path, format)) { yield return(loader.SendWebRequest()); isLoading = false; if (loader.isNetworkError) { ZLog.Warning("load the aidio error that msg = " + loader.error); NotifyManager.SendNotify(NotifyType.OnAudioLoadError, path); yield break; } AudioClip clip = null; if ((Application.platform == RuntimePlatform.WindowsPlayer || Application.platform == RuntimePlatform.WindowsEditor) && format == AudioType.MPEG) { clip = AudioUtil.FromMp3Data(loader.downloadHandler.data); } else { clip = DownloadHandlerAudioClip.GetContent(loader); } if (clip.length < 1) { ZLog.Warning("load the audio is empty that path = " + path); NotifyManager.SendNotify(NotifyType.OnAudioLoadError, path); yield break; } AudioInfo info = new AudioInfo { uid = uid, clip = clip }; clips.Add(info); if (isSound) { PlaySound(clip, target); } else { ActiveMusic(clip, target, loop); } NotifyManager.SendNotify(NotifyType.OnAudioPlay, path); } loadCoroutine = null; }
public void PlayMusic(string path, GameObject target, bool loop, AudioType format = AudioType.OGGVORBIS) { if (string.IsNullOrEmpty(path) || target.activeInHierarchy == false || isLoading) { return; } ZLog.Log("audio manager play one......path = " + path); string uid = AlgorithmUtil.ToMD5(path); AudioClip clip = GetClip(uid); if (clip == null) { if (File.Exists(path)) { //Debug.LogError("time read file start:" + Time.realtimeSinceStartup); //new Thread(() => ReadFile(uid, path, target, loop)).Start(); if (CallbackController.Instance == null) { ZLog.Error("must attach the script of CallbackController"); return; } if (loadCoroutine != null) { CallbackController.Instance.StopCoroutine(loadCoroutine); } loadCoroutine = CallbackController.Instance.StartCoroutine(LoadAndPlayDelay(uid, path, target, loop, false, format)); } else { ZLog.Error("the file not existed"); } } else { ActiveMusic(clip, target, loop); NotifyManager.SendNotify(NotifyType.OnAudioPlay, path); } }