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
    }
Ejemplo n.º 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
    }
Ejemplo n.º 3
0
        public async Task <ImportWallet> GetFundWallet(string fund)
        {
            try {
                var httpClientUtil = new HttpClientUtil();
                var client         = httpClientUtil.InitializeClient();

                client.DefaultRequestHeaders.Add("Authorization", "Basic YXBpOlIkX1hKZk1uNVdhaHlKaA==");

                Console.WriteLine("Getting external API information...");

                var streamTask    = client.GetStreamAsync("https://maisretorno.com/api/v1/fundos/get/" + fund + "/wallet/details/");
                var walletDetails = await JsonSerializer.DeserializeAsync <WalletDetails>(await streamTask);

                Console.WriteLine("Wallet details found!");
                Console.WriteLine("Building wallet object...");

                var importWallet = new ImportWallet();
                importWallet.Id       = Guid.NewGuid();
                importWallet.FundName = fund;
                importWallet.Assets   = new List <ImportAsset>();

                foreach (Children c in walletDetails.wallet.children)
                {
                    if (c.name.ToUpper().Equals("AÇÕES") || c.name.ToUpper().Equals("INVESTIMENTO NO EXTERIOR"))
                    {
                        importWallet.Total = c.sum;
                        foreach (Children a in c.children)
                        {
                            var asset = new ImportAsset();
                            asset.Id         = Guid.NewGuid();
                            asset.Name       = a.name;
                            asset.Size       = a.size;
                            asset.WalletId   = importWallet.Id;
                            asset.Percentage = Percentage.GetPercentage(a.size, importWallet.Total);

                            importWallet.Assets.Add(asset);
                        }
                    }
                }

                Console.WriteLine(importWallet);

                return(importWallet);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                throw ex;
            }
        }
    public void OnClickCreateDirectory()
    {
        Debug.Log("여긴 되나?");
        string _dir_name = _createField.text;

        if (_dir_name == "")
        {
            _createButton.gameObject.SetActive(true);
            _createField.gameObject.SetActive(false);
            _createField.text = "";
            return;
        }
        _dir_name = _createField.text;
        StartDBController _sd = _startDBController;

        if (_sd.directoryString.ContainsKey(_dir_name))
        {
            Debug.Log("여기서 막히나?");
            // 이미 이 이름의 디렉토리가 있어서 빠꾸쳐야함
            return;
        }

        /*
         * Directory 버튼 생성 부분인데 이거 솔직히 idx를 내가 직접 insert 해준다해도 prev_idx하고 다 찾아야하는데 난 자신없어서 냄겨둡니다.
         */
        //int _idx = _sd.directoryString[_createField.text];
        //int _prev_idx = _sd.directoryPoint[_idx];
        //Transform _parent = _sd.contentInfo[_prev_idx];
        //GameObject _tmp_btn = Instantiate(_startDBController._directorySampleBtn) as GameObject;
        //_tmp_btn.name = _dir_name;
        //_tmp_btn.transform.SetParent(_parent);
        //_tmp_btn.transform.GetChild(0).GetComponent<Text>().text = _dir_name;
        //_tmp_btn.transform.GetChild(2).GetComponent<Text>().text = _sd.directoryTime[_idx][_dir_name];
        //_tmp_btn.transform.GetComponent<VoiceDirectoryButton>()._key = _idx;
        //_tmp_btn.transform.GetComponent<VoiceDirectoryButton>()._prev_key = _prev_idx;
        //_tmp_btn.transform.GetComponent<VoiceDirectoryButton>()._change_btn = false;
        //_tmp_btn.SetActive(true);
        //_tmp_btn.transform.localScale = new Vector3(0.9f, 0.9f, 1);
        //string _lower = _dir_name.ToLower();
        //if (!_sd._currentSearch._fileTable.ContainsKey(_prev_idx))
        //{
        //    Dictionary<string, GameObject> sg = new Dictionary<string, GameObject>();
        //    _sd._currentSearch._fileTable.Add(_prev_idx, sg);
        //}
        //if (!_sd._currentSearch._fileTable[_prev_idx].ContainsKey(_lower))
        //{
        //    _tmp_btn = Instantiate(_sd._directorySampleBtn) as GameObject;
        //    _tmp_btn.name = _lower;
        //    _tmp_btn.transform.SetParent(_sd._current_content);
        //    _tmp_btn.transform.GetChild(0).GetComponent<Text>().text = _dir_name;
        //    _tmp_btn.transform.GetChild(2).GetComponent<Text>().text = _sd.directoryTime[_idx][_dir_name];
        //    _tmp_btn.transform.GetComponent<VoiceDirectoryButton>()._key = _idx;
        //    _tmp_btn.transform.GetComponent<VoiceDirectoryButton>()._prev_key = _prev_idx;
        //    _tmp_btn.transform.GetComponent<VoiceDirectoryButton>()._change_btn = false;
        //    _tmp_btn.SetActive(false);
        //    _tmp_btn.transform.localScale = new Vector3(0.9f, 0.9f, 1);
        //    _sd._currentSearch._fileTable[_prev_idx].Add(_lower, _tmp_btn);
        //}
        //if (!_sd._allSearch._fileTable.ContainsKey(_lower))
        //{
        //    _sd._allSearch._fileTable[_lower] = new List<GameObject>();
        //}
        //_tmp_btn = Instantiate(_sd._directorySampleBtn) as GameObject;
        //_tmp_btn.name = _lower;
        //_tmp_btn.transform.SetParent(_sd._all_content);
        //_tmp_btn.transform.GetChild(0).GetComponent<Text>().text = _dir_name;
        //_tmp_btn.transform.GetChild(2).GetComponent<Text>().text = _sd.directoryTime[_idx][_dir_name];
        //_tmp_btn.transform.GetComponent<VoiceDirectoryButton>()._key = _idx;
        //_tmp_btn.transform.GetComponent<VoiceDirectoryButton>()._prev_key = _prev_idx;
        //_tmp_btn.transform.GetComponent<VoiceDirectoryButton>()._change_btn = false;
        //_tmp_btn.SetActive(false);
        //_tmp_btn.transform.localScale = new Vector3(0.9f, 0.9f, 1);
        //_sd._allSearch._fileTable[_lower].Add(_tmp_btn);

        string _voiceDirectoryCreatePath;

        if (_sd._now > 0)
        {
            _voiceDirectoryCreatePath = _sd.directoryPath[_sd._now].Substring(1, _sd.directoryPath[_sd._now].Length - 1);
        }
        else
        {
            _voiceDirectoryCreatePath = "";
        }

        string _folderPath = @"" + Static.STATIC.dir_path + "/Resources/Voice" + _voiceDirectoryCreatePath + "/" + _dir_name;

        Directory.CreateDirectory(_folderPath);
        Debug.Log(_folderPath);
#if UNITY_EDITOR
        ImportAsset.NewImportAsset_File("Assets/Resources/Voice" + _voiceDirectoryCreatePath + "/" + _dir_name);
#endif

        //버튼, 컨텐츠 생성
        StartCoroutine(_sd.CreateDirectory(_voiceDirectoryCreatePath, _dir_name));

        _createButton.gameObject.SetActive(true);
        _createField.gameObject.SetActive(false);
        _createField.text = "";
    }
    public IEnumerator ClickedItem_Start()
    {
        _clickedItemPanel.SetActive(false);
        _basePanel.SetActive(false);
        _clickedItem = null;

        string        _path = dir_path + "/Database/";
        DirectoryInfo dir = new DirectoryInfo(_path);
        bool          _directory = false, _file = false;

        foreach (FileInfo file in dir.GetFiles())
        {
            if (file.Extension.ToLower().Equals(".sqlite"))
            {
                string[] fileName = file.Name.Split('.');

                if (fileName[0].Equals("VoiceDirectory"))
                {
                    _directory = true;
                }
                else if (fileName[0].Equals("VoiceFile"))
                {
                    _file = true;
                }
                if (_directory && _file)
                {
                    break;
                }
            }
        }

        _path = dir_path + "Resources/Voice/";
        dir   = new DirectoryInfo(_path);

        if (!_directory)
        {
            VRDBController.VoiceDirectory_Init();
            string   tmp       = dir.LastWriteTime.ToString();
            string[] lastWrite = tmp.Split(' ');
            VRDBController.VoiceDirectory_add(dir.Name, lastWrite[0], 0, 0);
            yield return(StartCoroutine(GetVoiceDirectory(dir_path + "/Resources/Voice/", "", 0)));

#if UNITY_EDITOR
            ImportAsset.NewImportAsset_File("Assets/DataBase/VoiceDirectory.sqlite");
#endif
        }
        else
        {
            VRDBController.ConIn(dir_path + "/DataBase/VoiceDirectory");
        }

        VRDBController.VoiceDirectory_Start();

        if (!_file)
        {
            VRDBController.VoiceFile_Init();
            yield return(StartCoroutine(GetVoiceFile(dir_path + "/Resources/Voice/", "Voice/", "")));

#if UNITY_EDITOR
            ImportAsset.NewImportAsset_File("Assets/DataBase/VoiceFile.sqlite");
#endif
        }
        else
        {
            VRDBController.ConIn(dir_path + "/DataBase/VoiceFile");
        }

        VRDBController.VoiceFile_Start();
        VRDBController.VoiceAudio_Start();

        yield return(null);
    }