반응형

public static void BundleSoundMoveToAddressableFolder(bool isRefreshWhenEnd)
    {
        FileInfo curF = null;
        try
        {
            DirectoryInfo dir = new DirectoryInfo("Assets/Editor/FMOD/BundleSound");
            FileInfo[] info = dir.GetFiles("*.*");
            foreach (FileInfo f in info)
            {
                curF = f;
                int idx = f.Name.IndexOf('.');
                string name = f.Name;
                string nameWithOutExtention = name.Substring(0, idx);
                string[] nameSplit = nameWithOutExtention.Split('_');

                int packNumber = 0;
                for (int i = 0; i < nameSplit.Length; i++)
                {
                    string nameSplitWithOutExtention = Path.GetFileNameWithoutExtension(nameSplit[i]);
                    int.TryParse(nameSplitWithOutExtention, out packNumber);
                }

                bool isMoveToCommon = false;

                //팩에 해당한는 리소스
                if (packNumber > 0)
                {
                    string packNumberFolderName = string.Format("Pack_{0:D2}", packNumber);
                    string destPackFolderPath = string.Format(destinationPackFolderPath, packNumber);
                    if (f.Name.Contains("Character_Pack"))
                    {
                        //(임시)Character_Pack이름 적힌 리소스는 Addressable폴더에 Common 폴더로
                        isMoveToCommon = true;
                    }
                    else if (Directory.Exists(destPackFolderPath) == false)
                    {
                        //pack폴더 없다면 옮기지않음
                        continue;
                        //pack폴더 없다면 Addressable폴더에 Common 폴더로
                        //isMoveToCommon = true;
                        
                    }
                    else if (f.Name.Contains(packNumberFolderName))
                    {
                        //팩에 해당하는 파일이면 Addressable폴더의 Pack 폴더로
                        FileUtil.ReplaceFile($"{sourceFolderPath}/{name}", $"{string.Format(destinationPackFolderPath, packNumber)}/{name}");

                    }
                    else // 해당되지 않은 것들은 Addressable폴더에 Common 폴더로
                    {
                        isMoveToCommon = true;

                    }



                }
                else //팩이아닌 리소스
                {
                    if (soundListBelongToResourcesFolder.Contains(nameWithOutExtention))
                    {
                        //Resouces 파일에 해당하는 것은 Resources 폴더로
                        FileUtil.ReplaceFile($"{sourceFolderPath}/{name}", $"{destinationSoundMasterFolderPath}/{name}");
                    }
                    else // 해당되지 않은 것들은 Addressable폴더에 Common 폴더로
                        isMoveToCommon = true;
                }

                if (isMoveToCommon)
                {
                    FileUtil.ReplaceFile($"{sourceFolderPath}/{name}", $"{destinationCommonFolderPath}/{name}");
                }
            }
        }
        catch(System.Exception e)
        {
            Debug.LogError($"ex :  {curF.Name} / {curF.FullName} / {curF.DirectoryName} ");
        }
        if (isRefreshWhenEnd)
        {
            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh();
        }
    }

반응형

+ Recent posts