Exemplo n.º 1
0
            public string FileNameToPath(string fileName, string LocalizeDir)
            {
                if (string.IsNullOrEmpty(fileName))
                {
                    return(fileName);
                }

                string path;

                //既に絶対URLならそのまま
                if (FilePathUtil.IsAbsoluteUri(fileName))
                {
                    path = fileName;
                }
                else
                {
                    try
                    {
                        //拡張子がなければデフォルト拡張子を追加
                        if (string.IsNullOrEmpty(FilePathUtil.GetExtension(fileName)))
                        {
                            fileName += defaultExt;
                        }
                        path = defaultDir + LocalizeDir + "/" + fileName;
                    }
                    catch (System.Exception e)
                    {
                        Debug.LogError(fileName + "  " + e.ToString());
                        path = defaultDir + LocalizeDir + "/" + fileName;
                    }
                }

                //プラットフォームが対応する拡張子にする(mp3とoggを入れ替え)
                return(ExtensionUtil.ChangeSoundExt(path));
            }
Exemplo n.º 2
0
        public static string ChangeSoundExt(string path)
        {
            string str = FilePathUtil.GetExtension(path).ToLower();

            if (str == null)
            {
                return(path);
            }
            if (!(str == ".ogg"))
            {
                if (str != ".mp3")
                {
                    return(path);
                }
            }
            else
            {
                if (IsSupportOggPlatform())
                {
                    return(path);
                }
                return(FilePathUtil.ChangeExtension(path, ".mp3"));
            }
            if (!IsSupportOggPlatform())
            {
                return(path);
            }
            return(FilePathUtil.ChangeExtension(path, ".ogg"));
        }
Exemplo n.º 3
0
        /// <summary>
        /// WebPlayer、StandAloneではOggが対応。MOBILEはMP3が非対応なので、拡張子を入れ替える
        /// http://docs-jp.unity3d.com/Documentation/ScriptReference/WWW.GetAudioClip.html
        /// </summary>
        /// <param name="path">ファイルパス</param>
        /// <returns>対応するサウンドの拡張子を入れ替えたファイルパス</returns>
        public static string ChangeSoundExt(string path)
        {
            string ext = FilePathUtil.GetExtension(path).ToLower();

            switch (ext)
            {
            case Ogg:
                if (!IsSupportOggPlatform())
                {
                    return(FilePathUtil.ChangeExtension(path, Mp3));
                }
                break;

            case Mp3:
                if (IsSupportOggPlatform())
                {
                    return(FilePathUtil.ChangeExtension(path, Ogg));
                }
                break;

            default:
                break;
            }
            return(path);
        }
Exemplo n.º 4
0
        public static AudioType GetAudioType(string path)
        {
            switch (FilePathUtil.GetExtension(path).ToLower())
            {
            case ".mp3":
                return(13);

            case ".ogg":
                return(14);
            }
            return(20);
        }
Exemplo n.º 5
0
        /// <summary>
        /// オーディオのタイプを取得
        /// </summary>
        /// <param name="path">ファイルパス</param>
        /// <returns>オーディオのタイプ</returns>
        public static AudioType GetAudioType(string path)
        {
            string ext = FilePathUtil.GetExtension(path).ToLower();

            switch (ext)
            {
            case Mp3:
                return(AudioType.MPEG);

            case Ogg:
                return(AudioType.OGGVORBIS);

            default:
                return(AudioType.WAV);
            }
        }
Exemplo n.º 6
0
        string GetPathChangedSoundExt(string path)
        {
            if (!loadLegacySoundExt)
            {
                return("");
            }
            string ext = FilePathUtil.GetExtension(path);

            if (string.Compare(ext, ".ogg", true) == 0)
            {
                return(FilePathUtil.ChangeExtension(path, ".mp3"));
            }
            else if (string.Compare(ext, ".mp3", true) == 0)
            {
                return(FilePathUtil.ChangeExtension(path, ".ogg"));
            }
            return("");
        }
Exemplo n.º 7
0
            public string FileNameToPath(string fileName, string LocalizeDir)
            {
                if (string.IsNullOrEmpty(fileName))
                {
                    return(fileName);
                }

                string path;

/*				//既に絶対URLならそのまま
 *                              if (FilePathUtil.IsAbsoluteUri(fileName))
 *                              {
 *                                      path = fileName;
 *                              }
 *                              else*/
                {
                    try
                    {
                        //拡張子がなければデフォルト拡張子を追加
                        if (string.IsNullOrEmpty(FilePathUtil.GetExtension(fileName)))
                        {
                            fileName += defaultExt;
                        }
                        path = defaultDir + LocalizeDir + "/" + fileName;
                    }
                    catch (System.Exception e)
                    {
                        Debug.LogError(fileName + "  " + e.ToString());
                        path = defaultDir + LocalizeDir + "/" + fileName;
                    }
                }
                if (legacyAutoChangeSoundExt)
                {
                    //プラットフォームが対応する拡張子にする(mp3とoggを入れ替え)
                    //ファイルを直接使う場合は必要だった処理だが、デバッグログでも拡張子が変わって混乱ケースがあるので廃止
                    return(ExtensionUtil.ChangeSoundExt(path));
                }
                else
                {
                    return(path);
                }
            }
Exemplo n.º 8
0
        /// <summary>
        /// ファイル名をパスに
        /// </summary>
        /// <param name="fileName">ファイル名</param>
        /// <returns>ファイルパス</returns>
        public string ScenaioFileToPath(string scenaioFile)
        {
            //既に絶対URLならそのまま
            if (FilePathUtil.IsAbsoluteUri(scenaioFile))
            {
                return(scenaioFile);
            }
            else
            {
                //拡張子がなければデフォルト拡張子を追加
                if (string.IsNullOrEmpty(FilePathUtil.GetExtension(scenaioFile)))
                {
                    scenaioFile += defaultExt;
                }

                //旧形式(ファイル分割なし)に対応
                if (!scenaioFile.Contains("/"))
                {
                    scenaioFile = "Scenario/" + scenaioFile;
                }
                return(FilePathUtil.Combine(defaultDir, scenaioFile));
            }
        }