/** * <summary>Gets the AudioClip associated with a speech line</summary> * <param name = "lineID">The ID number of the speech line, as generated by the Speech Manager</param> * <param name = "_speaker">The character speaking the line</param> * <returns>Gets the AudioClip associated with a speech line</returns> */ public AudioClip GetSpeechAudioClip(int lineID, Char _speaker) { AudioClip clipObj = null; int voiceLanguage = Options.GetVoiceLanguage(); string voiceLanguageName = (voiceLanguage > 0) ? Options.GetVoiceLanguageName() : string.Empty; if (KickStarter.speechManager.autoNameSpeechFiles) { string fullName = KickStarter.speechManager.GetAutoAssetPathAndName(lineID, _speaker, voiceLanguageName, false); if (currentAudioAssetBundle != null) { // Asset bundles if (isLoadingBundle) { ACDebug.LogWarning("Cannot load audio file from AssetBundle as the AssetBundle is still being loaded."); return(null); } else { int indexOfLastSlash = fullName.LastIndexOf("/") + 1; if (indexOfLastSlash > 0) { fullName = fullName.Substring(indexOfLastSlash); } clipObj = currentAudioAssetBundle.LoadAsset <AudioClip> (fullName); if (clipObj == null && !string.IsNullOrEmpty(fullName)) { ACDebug.LogWarning("Audio file '" + fullName + "' not found in Asset Bundle '" + currentAudioAssetBundle.name + "'."); } } } else { // Resources clipObj = Resources.Load(fullName) as AudioClip; if (clipObj == null && KickStarter.speechManager.fallbackAudio && voiceLanguage > 0) { fullName = KickStarter.speechManager.GetAutoAssetPathAndName(lineID, _speaker, string.Empty, false); clipObj = Resources.Load(fullName) as AudioClip; } if (clipObj == null && !string.IsNullOrEmpty(fullName)) { ACDebug.LogWarning("Audio file 'Resources/" + fullName + "' not found in Resources folder."); } } } else { clipObj = GetLineCustomAudioClip(lineID, voiceLanguage); if (clipObj == null && KickStarter.speechManager.fallbackAudio && voiceLanguage > 0) { clipObj = GetLineCustomAudioClip(lineID, 0); } } return(clipObj); }
/** * <summary>Gets the AudioClip associated with a speech line</summary> * <param name = "lineID">The ID number of the speech line, as generated by the Speech Manager</param> * <param name = "_speaker">The character speaking the line</param> * <returns>Gets the AudioClip associated with a speech line</returns> */ public virtual AudioClip GetSpeechAudioClip(int lineID, Char _speaker) { if (!KickStarter.speechManager.IsTextTypeTranslatable(AC_TextType.Speech)) { return(null); } int voiceLanguage = Options.GetVoiceLanguage(); string voiceLanguageName = (voiceLanguage > 0) ? Options.GetVoiceLanguageName() : string.Empty; switch (KickStarter.speechManager.referenceSpeechFiles) { case ReferenceSpeechFiles.ByNamingConvention: { string fullName = KickStarter.speechManager.GetAutoAssetPathAndName(lineID, _speaker, voiceLanguageName, false); AudioClip clipObj = Resources.Load(fullName) as AudioClip; if (clipObj == null && KickStarter.speechManager.fallbackAudio && voiceLanguage > 0) { fullName = KickStarter.speechManager.GetAutoAssetPathAndName(lineID, _speaker, string.Empty, false); clipObj = Resources.Load(fullName) as AudioClip; } if (clipObj == null && !string.IsNullOrEmpty(fullName)) { ACDebug.LogWarning("Audio file 'Resources/" + fullName + "' not found in Resources folder."); } return(clipObj); } case ReferenceSpeechFiles.ByAssetBundle: { if (isLoadingBundle) { ACDebug.LogWarning("Cannot load audio file from AssetBundle as the AssetBundle is still being loaded."); return(null); } string fullName = KickStarter.speechManager.GetAutoAssetPathAndName(lineID, _speaker, voiceLanguageName, false); int indexOfLastSlash = fullName.LastIndexOf("/") + 1; if (indexOfLastSlash > 0) { fullName = fullName.Substring(indexOfLastSlash); } if (currentAudioAssetBundle == null) { ACDebug.LogWarning("Cannot load audio file '" + fullName + "' from AssetBundle as no AssetBundle is currently loaded."); return(null); } AudioClip clipObj = currentAudioAssetBundle.LoadAsset <AudioClip> (fullName); if (clipObj == null && !string.IsNullOrEmpty(fullName)) { ACDebug.LogWarning("Audio file '" + fullName + "' not found in Asset Bundle '" + currentAudioAssetBundle.name + "'."); } return(clipObj); } case ReferenceSpeechFiles.ByDirectReference: { AudioClip clipObj = GetLineCustomAudioClip(lineID, voiceLanguage); if (clipObj == null && KickStarter.speechManager.fallbackAudio && voiceLanguage > 0) { return(GetLineCustomAudioClip(lineID, 0)); } return(clipObj); } } return(null); }
/** * <summary>Gets the lipsync file associated with a speech line</summary> * <param name = "lineID">The ID number of the speech line, as generated by the Speech Manager</param> * <param name = "_speaker">The character speaking the line</param> * <returns>Gets the lipsync file associated with a speech line</returns> */ public T GetSpeechLipsyncFile <T> (int lineID, Char _speaker) where T : Object { T lipsyncFile = null; int voiceLanguage = Options.GetVoiceLanguage(); string voiceLanguageName = (voiceLanguage > 0) ? Options.GetVoiceLanguageName() : string.Empty; if (KickStarter.speechManager.autoNameSpeechFiles) { string fullName = KickStarter.speechManager.GetAutoAssetPathAndName(lineID, _speaker, voiceLanguageName, true); if (currentLipsyncAssetBundle != null) { // Asset bundles if (isLoadingBundle) { ACDebug.LogWarning("Cannot load lipsync file from AssetBundle as the AssetBundle is still being loaded."); return(null); } int indexOfLastSlash = fullName.LastIndexOf("/") + 1; if (indexOfLastSlash > 0) { fullName = fullName.Substring(indexOfLastSlash); } lipsyncFile = currentLipsyncAssetBundle.LoadAsset <T> (fullName); if (lipsyncFile == null && !string.IsNullOrEmpty(fullName)) { ACDebug.LogWarning("Lipsync file '" + fullName + "' (" + typeof(T) + ") not found in Asset Bundle '" + currentLipsyncAssetBundle.name + "'."); } } else { // Resources lipsyncFile = Resources.Load(fullName) as T; if (lipsyncFile == null && KickStarter.speechManager.fallbackAudio && voiceLanguage > 0) { fullName = KickStarter.speechManager.GetAutoAssetPathAndName(lineID, _speaker, string.Empty, true); lipsyncFile = Resources.Load(fullName) as T; } if (lipsyncFile == null) { ACDebug.LogWarning("Lipsync file 'Resources/" + fullName + "' (" + typeof(T) + ") not found in Resources folder."); } } } else { UnityEngine.Object _object = KickStarter.runtimeLanguages.GetLineCustomLipsyncFile(lineID, voiceLanguage); if (_object == null && KickStarter.speechManager.fallbackAudio && voiceLanguage > 0) { _object = KickStarter.runtimeLanguages.GetLineCustomLipsyncFile(lineID, 0); } if (_object is T) { lipsyncFile = (T)KickStarter.runtimeLanguages.GetLineCustomLipsyncFile(lineID, voiceLanguage); } } return(lipsyncFile); }
/** * <summary>Gets the lipsync file associated with a speech line</summary> * <param name = "lineID">The ID number of the speech line, as generated by the Speech Manager</param> * <param name = "_speaker">The character speaking the line</param> * <returns>Gets the lipsync file associated with a speech line</returns> */ public virtual T GetSpeechLipsyncFile <T> (int lineID, Char _speaker) where T : Object { if (!KickStarter.speechManager.IsTextTypeTranslatable(AC_TextType.Speech)) { return(null); } int voiceLanguage = Options.GetVoiceLanguage(); string voiceLanguageName = (voiceLanguage > 0) ? Options.GetVoiceLanguageName() : string.Empty; switch (KickStarter.speechManager.referenceSpeechFiles) { case ReferenceSpeechFiles.ByNamingConvention: { string fullName = KickStarter.speechManager.GetAutoAssetPathAndName(lineID, _speaker, voiceLanguageName, true); T lipsyncFile = Resources.Load(fullName) as T; if (lipsyncFile == null && KickStarter.speechManager.fallbackAudio && voiceLanguage > 0) { fullName = KickStarter.speechManager.GetAutoAssetPathAndName(lineID, _speaker, string.Empty, true); lipsyncFile = Resources.Load(fullName) as T; } if (lipsyncFile == null) { ACDebug.LogWarning("Lipsync file 'Resources/" + fullName + "' (" + typeof(T) + ") not found in Resources folder."); } return(lipsyncFile); } case ReferenceSpeechFiles.ByAssetBundle: { string fullName = KickStarter.speechManager.GetAutoAssetPathAndName(lineID, _speaker, voiceLanguageName, true); if (isLoadingBundle) { ACDebug.LogWarning("Cannot load lipsync file from AssetBundle as the AssetBundle is still being loaded."); return(null); } int indexOfLastSlash = fullName.LastIndexOf("/") + 1; if (indexOfLastSlash > 0) { fullName = fullName.Substring(indexOfLastSlash); } if (currentLipsyncAssetBundle == null) { ACDebug.LogWarning("Cannot load lipsync file '" + fullName + "' from AssetBundle as no AssetBundle is currently loaded."); return(null); } T lipsyncFile = currentLipsyncAssetBundle.LoadAsset <T> (fullName); if (lipsyncFile == null && !string.IsNullOrEmpty(fullName)) { ACDebug.LogWarning("Lipsync file '" + fullName + "' (" + typeof(T) + ") not found in Asset Bundle '" + currentLipsyncAssetBundle.name + "'."); } return(lipsyncFile); } case ReferenceSpeechFiles.ByDirectReference: { UnityEngine.Object _object = KickStarter.runtimeLanguages.GetLineCustomLipsyncFile(lineID, voiceLanguage); if (_object == null && KickStarter.speechManager.fallbackAudio && voiceLanguage > 0) { _object = KickStarter.runtimeLanguages.GetLineCustomLipsyncFile(lineID, 0); } if (_object is T) { return((T)KickStarter.runtimeLanguages.GetLineCustomLipsyncFile(lineID, voiceLanguage)); } } break; } return(null); }