IEnumerator SaveAndDownload(string url, string localPath, string fileName)
    {
        WWW www = new WWW(url);

        Debug.Log(url);

        yield return(www);

        byte[] bytes = www.bytes;

        Debug.Log("<color=red>" + bytes.Length + "</color>");

        if (!Directory.Exists(localPath))
        {
            Directory.CreateDirectory(localPath);
#if UNITY_EDITOR
            /* 동적으로 폴더에 있는 데이터 임포트! -> 유니티 상에서 바로 사용 할 수 있도록
             * 에디터 모드에만 적용되는 소스를 전처리기 적용 우회시켜 빌드 모드에서도 적용할 수 있도록 설정!
             */
            ImportAsset.NewImportAsset_Dic("Assets/AssetBundles");
#endif
        }

        Debug.Log(localPath + " + " + fileName);

        File.WriteAllBytes(localPath + fileName, bytes);

#if UNITY_EDITOR
        /* 동적으로 폴더에 있는 데이터 임포트! -> 유니티 상에서 바로 사용 할 수 있도록
         * 에디터 모드에만 적용되는 소스를 전처리기 적용 우회시켜 빌드 모드에서도 적용할 수 있도록 설정!
         */
        ImportAsset.NewImportAsset_File("Assets/AssetBundles/" + fileName);
#endif
    }
Exemple #2
0
    public void MoveVoiceFile(string path, string title)
    {
        StartDBController _sd = _startDBController;
        DirectoryInfo     dir = new DirectoryInfo(path);

        /* 생성되는 파일을 옮길 경로 및 이름 표기 */
        string loadDir  = dir_path + "/Resources/Voice";
        string modelDir = null;

        foreach (FileInfo file in dir.GetFiles())
        {
            /* 메타 파일이 생성됬을 때 지우도록! */
            DeleteFile(path, file.Name, ".meta");

            /* 생성된 음성 파일 -> 각 모델 디렉토리 이동 */
            if (file.Extension.ToLower().CompareTo(".wav") == 0)
            {
                // 여기 수정
                if (_sd._now > 0 && modelDir == null)
                {
                    modelDir = _sd.directoryPath[_sd._now].Substring(1, _sd.directoryPath[_sd._now].Length - 1);
                    loadDir += modelDir + "/" + title + ".wav";
                }

                /* 같은 이름을 가진 파일이 있으면, 덮어 씌우도록 설정. */
                if (ExistSameNameFile(loadDir))
                {
                    file.CopyTo(@loadDir, true);
                    file.Delete();
                    /* 유니티 Slot에도 덮어 씌울 수 있도록 코드 수정 필요 */
                }
                else // 새 파일 생성 시 버튼도 같이 생성!
                {
                    file.MoveTo(loadDir);
                    string   tmp       = file.LastWriteTime.ToString();
                    string[] lastWrite = tmp.Split(' ');

#if UNITY_EDITOR
                    /* 동적으로 폴더에 있는 데이터 임포트! -> 유니티 상에서 바로 사용 할 수 있도록
                     * 에디터 모드에만 적용되는 소스를 전처리기 적용 우회시켜 빌드 모드에서도 적용할 수 있도록 설정!
                     */
                    ImportAsset.NewImportAsset_Dic("Assets/Resources/Voice" + modelDir);
#endif
                    // 여기 수정
                    /* 음성 Slot을 만들어준다. */
                    StartCoroutine(_startDBController.CreateFile(title, ".wav", lastWrite[0]));
                }
                //
            }

            //냅두고
            /* 생성된 그래프 파일 -> 삭제 */
            else if (file.Extension.ToLower().CompareTo(".png") == 0)
            {
                file.Delete(); // 파일 삭제
            }
        }//foreach
    }