コード例 #1
0
    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
    }
コード例 #2
0
    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 = "";
    }
コード例 #3
0
    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);
    }