public void DeleteDirectory(int idx) { if (directoryPath.ContainsKey(idx)) { directoryPath.Remove(idx); } if (directoryPoint.ContainsKey(idx)) { directoryPoint.Remove(idx); } if (directoryTime.ContainsKey(idx)) { directoryTime.Remove(idx); } if (fileInfo.ContainsKey(idx)) { fileInfo.Remove(idx); } if (fileTime.ContainsKey(idx)) { fileTime.Remove(idx); } if (idxInfo.Contains(idx)) { idxInfo.Remove(idx); } if (audioInfo.ContainsKey(idx)) { audioInfo.Remove(idx); } if (directoryInteger.ContainsKey(idx)) { if (directoryString.ContainsKey(directoryInteger[idx])) { directoryString.Remove(directoryInteger[idx]); } if (directoryName.Contains(directoryInteger[idx])) { directoryName.Remove(directoryInteger[idx]); } directoryInteger.Remove(idx); } if (contentInfo.ContainsKey(idx)) { contentInfo.Remove(idx); } if (directoryPathIdx.ContainsKey(idx)) { foreach (int i in directoryPathIdx[idx]) { DeleteDirectory(i); } directoryPathIdx.Remove(idx); } VRDBController.VoiceDirectory_DeleteKey(idx); VRDBController.VoiceFile_DeleteKey(idx); }
private IEnumerator GetVoiceDirectory(string cur_path, string nxt_path, int cur) { string _path = cur_path + nxt_path; DirectoryInfo dir = new DirectoryInfo(_path); int cur_idx = cur; foreach (DirectoryInfo d in dir.GetDirectories()) { string tmp = d.LastWriteTime.ToString(); string[] lastWrite = tmp.Split(' '); VRDBController.VoiceDirectory_add(d.Name, lastWrite[0], ++idx, cur_idx); StartCoroutine(GetVoiceDirectory(_path, d.Name + "/", idx)); } yield return(null); }
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); }
public void DeleteFile(int idx, string name) { string[] name2 = name.Split('.'); if (audioInfo.ContainsKey(idx)) { if (audioInfo[idx].ContainsKey(name2[0])) { audioInfo[idx].Remove(name2[0]); } } if (fileInfo.ContainsKey(idx)) { fileInfo[idx].Remove(name); } if (fileTime.ContainsKey(idx)) { if (fileTime[idx].ContainsKey(name)) { fileTime[idx].Remove(name); } } VRDBController.VoiceFile_DeleteName(idx, name); }
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); }
public IEnumerator CreateDirectory(string cur_path, string dir_name) { int cur_idx = -1; for (int i = 0; i < idxInfo.Count; ++i) { if (cur_idx < idxInfo[i]) { cur_idx = idxInfo[i]; } } idxInfo.Add(++cur_idx); if (!directoryString.ContainsKey(dir_name)) { directoryString.Add(dir_name, cur_idx); } if (!directoryInteger.ContainsKey(cur_idx)) { directoryInteger.Add(cur_idx, dir_name); } if (!directoryPoint.ContainsKey(cur_idx)) { directoryPoint.Add(cur_idx, _now); } DirectoryInfo dir = new DirectoryInfo(@"" + Static.STATIC.dir_path + "/Resources/Voice" + cur_path + "/" + dir_name); string dir_time = dir.LastWriteTime.ToString(); string[] lastWrite = dir_time.Split(' '); if (!directoryTime.ContainsKey(cur_idx)) { Dictionary <string, string> ss = new Dictionary <string, string>(); directoryTime.Add(cur_idx, ss); } if (!directoryTime[cur_idx].ContainsKey(dir_name)) { directoryTime[cur_idx].Add(dir_name, lastWrite[0]); } directoryName.Add(dir_name); if (!directoryPath.ContainsKey(cur_idx)) { directoryPath.Add(cur_idx, "." + cur_path + "/" + dir_name); } directoryPathIdx[_now].Add(cur_idx); // DB VRDBController.ConIn(Static.STATIC.dir_path + "/DataBase/VoiceDirectory"); VRDBController.VoiceDirectory_add(dir_name, lastWrite[0], cur_idx, _now); Debug.Log("Name: " + dir_name + ", Time:" + lastWrite[0] + ", idx:" + cur_idx + ", prev_idx:" + _now); // 컨텐츠 생성 Transform _parent = _viewPort; Transform tmp_content = Instantiate(_content); if (!contentInfo.ContainsKey(cur_idx)) { tmp_content.SetParent(_viewPort); tmp_content.name = dir_name; tmp_content.localScale = new Vector3(1, 1, 1); tmp_content.GetComponent <RectTransform>().localPosition = new Vector3(0, 0, 0); tmp_content.GetComponent <RectTransform>().offsetMax = new Vector2(0, 0); tmp_content.GetChild(0).GetComponent <VoiceDirectoryButton>()._key = cur_idx; tmp_content.GetChild(0).GetComponent <VoiceDirectoryButton>()._prev_key = _now; tmp_content.gameObject.SetActive(false); contentInfo.Add(cur_idx, tmp_content); } // 버튼 생성 _parent = contentInfo[_now]; GameObject tmp_btn = Instantiate(_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 = directoryTime[cur_idx][dir_name]; tmp_btn.transform.GetComponent <VoiceDirectoryButton>()._key = cur_idx; tmp_btn.transform.GetComponent <VoiceDirectoryButton>()._prev_key = _now; 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 (!_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(_directorySampleBtn) as GameObject; tmp_btn.name = _lower; tmp_btn.transform.SetParent(_current_content); tmp_btn.transform.GetChild(0).GetComponent <Text>().text = dir_name; tmp_btn.transform.GetChild(2).GetComponent <Text>().text = directoryTime[cur_idx][dir_name]; tmp_btn.transform.GetComponent <VoiceDirectoryButton>()._key = cur_idx; tmp_btn.transform.GetComponent <VoiceDirectoryButton>()._prev_key = _now; tmp_btn.transform.GetComponent <VoiceDirectoryButton>()._change_btn = false; 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(_directorySampleBtn) as GameObject; tmp_btn.name = _lower; tmp_btn.transform.SetParent(_all_content); tmp_btn.transform.GetChild(0).GetComponent <Text>().text = dir_name; tmp_btn.transform.GetChild(2).GetComponent <Text>().text = directoryTime[cur_idx][dir_name]; tmp_btn.transform.GetComponent <VoiceDirectoryButton>()._key = cur_idx; tmp_btn.transform.GetComponent <VoiceDirectoryButton>()._prev_key = _now; tmp_btn.transform.GetComponent <VoiceDirectoryButton>()._change_btn = false; 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); }
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); }