private IEnumerator GetVoiceFile(string cur_path, string l_path, string nxt_path)
    {
        string        _path  = cur_path + nxt_path;
        string        _path2 = l_path + nxt_path;
        DirectoryInfo dir    = new DirectoryInfo(_path);
        int           cur_idx;

        if (!_startDBController.directoryString.ContainsKey(dir.Name))
        {
            cur_idx = 0;
        }
        else
        {
            cur_idx = _startDBController.directoryString[dir.Name];
        }

        foreach (FileInfo f in dir.GetFiles())
        {
            if (f.Extension.ToLower().Equals(".meta"))
            {
                continue;
            }
            else if (f.Extension.Equals(".mp3") || f.Extension.Equals(".wav") || f.Extension.Equals(".aac") || f.Extension.Equals(".flac"))
            {
                string[] fname     = f.Name.Split('.');
                string   tmp       = f.LastWriteTime.ToString();
                string[] lastWrite = tmp.Split(' ');

                VRDBController.VoiceFile_add(f.Name, lastWrite[0], cur_idx);
                VRDBController.VoiceAudio_add(fname[0], _path2, cur_idx);
            }
        }

        foreach (DirectoryInfo d in dir.GetDirectories())
        {
            StartCoroutine(GetVoiceFile(_path, _path2, d.Name + "/"));
        }

        yield return(null);
    }
示例#2
0
    public IEnumerator CreateFile(string file_name, string extension, string lastWrite)
    {
        // 새로 만든 폴더일 경우 fileInfo엔 정보가 없을 거임.
        if (!fileInfo.ContainsKey(_now))
        {
            fileInfo[_now] = new List <string>();
        }
        fileInfo[_now].Add(file_name + extension);
        if (!fileTime.ContainsKey(_now))
        {
            Dictionary <string, string> ss = new Dictionary <string, string>();
            fileTime.Add(_now, ss);
        }
        if (!fileTime[_now].ContainsKey(file_name + extension))
        {
            fileTime[_now].Add(file_name + extension, lastWrite);
        }
        string    _path     = "Voice" + directoryPath[_now].Substring(1, directoryPath[_now].Length - 1);
        AudioClip tmp_audio = Resources.Load <AudioClip>(_path + "/" + file_name);

        if (!audioInfo.ContainsKey(_now))
        {
            Dictionary <string, AudioClip> sa = new Dictionary <string, AudioClip>();
            audioInfo.Add(_now, sa);
        }
        if (!audioInfo[_now].ContainsKey(file_name))
        {
            audioInfo[_now].Add(file_name, tmp_audio);
        }

        // DB
        VRDBController.ConIn(Static.STATIC.dir_path + "/DataBase/VoiceFile");
        VRDBController.VoiceFile_add(file_name + extension, lastWrite, _now);
        VRDBController.VoiceAudio_add(file_name, _path + "/", _now);

        // 버튼 생성
        Transform  _parent = contentInfo[_now];
        GameObject tmp_btn = Instantiate(_fileSampleBtn) as GameObject;

        tmp_btn.name = file_name + extension;
        tmp_btn.transform.SetParent(_parent);
        tmp_btn.transform.GetChild(0).GetComponent <Text>().text = file_name + extension;
        tmp_btn.transform.GetChild(2).GetComponent <Text>().text = fileTime[_now][file_name + extension];
        tmp_btn.GetComponent <AudioSource>().clip           = audioInfo[_now][file_name];
        tmp_btn.GetComponent <VoiceFileButton>()._key       = _now;
        tmp_btn.GetComponent <VoiceFileButton>()._file_name = file_name;
        tmp_btn.SetActive(true);
        tmp_btn.transform.localScale = new Vector3(0.9f, 0.9f, 1);
        string _lower = (file_name + extension).ToLower();

        if (!_currentSearch._fileTable.ContainsKey(_now))
        {
            Dictionary <string, GameObject> sg = new Dictionary <string, GameObject>();
            _currentSearch._fileTable.Add(_now, sg);
        }
        if (!_currentSearch._fileTable[_now].ContainsKey(_lower))
        {
            tmp_btn      = Instantiate(_fileSampleBtn) as GameObject;
            tmp_btn.name = _lower;
            tmp_btn.transform.SetParent(_current_content);
            tmp_btn.transform.GetChild(0).GetComponent <Text>().text = file_name + extension;
            tmp_btn.transform.GetChild(2).GetComponent <Text>().text = fileTime[_now][file_name + extension];
            tmp_btn.GetComponent <AudioSource>().clip           = audioInfo[_now][file_name];
            tmp_btn.GetComponent <VoiceFileButton>()._key       = _now;
            tmp_btn.GetComponent <VoiceFileButton>()._file_name = file_name;
            tmp_btn.SetActive(false);
            tmp_btn.transform.localScale = new Vector3(0.9f, 0.9f, 1);
            _currentSearch._fileTable[_now].Add(_lower, tmp_btn);
        }
        if (!_allSearch._fileTable.ContainsKey(_lower))
        {
            _allSearch._fileTable[_lower] = new List <GameObject>();
        }
        tmp_btn      = Instantiate(_fileSampleBtn) as GameObject;
        tmp_btn.name = _lower;
        tmp_btn.transform.SetParent(_all_content);
        tmp_btn.transform.GetChild(0).GetComponent <Text>().text = file_name + extension;
        tmp_btn.transform.GetChild(2).GetComponent <Text>().text = fileTime[_now][file_name + extension];
        tmp_btn.GetComponent <AudioSource>().clip           = audioInfo[_now][file_name];
        tmp_btn.GetComponent <VoiceFileButton>()._key       = _now;
        tmp_btn.GetComponent <VoiceFileButton>()._file_name = file_name;
        tmp_btn.SetActive(false);
        tmp_btn.transform.localScale = new Vector3(0.9f, 0.9f, 1);
        _allSearch._fileTable[_lower].Add(tmp_btn);
        _allSearch.root.insert(_lower + '\0', 0);

        yield return(null);
    }