Ejemplo n.º 1
0
    /* 삭제 버튼을 클릭하면 실행되는 함수 */
    public void OnClickDelete()
    {
        string _voiceDirectoryPath;

        if (_startDBController._filePath.Length > 1)                                                                  //경로 깊이가 1 이상일 때는
        {
            _voiceDirectoryPath = _startDBController._filePath.Substring(1, _startDBController._filePath.Length - 1); //. 없애기
        }
        else
        {
            _voiceDirectoryPath = "";                                                                           //경로 없음
        }
        FileInfo _file = new FileInfo(@"Assets/Resources/Voice" + _voiceDirectoryPath + "/" + gameObject.name); //본 파일 삭제

        if (_file.Exists)                                                                                       //파일 존재하면
        {
            _file.IsReadOnly = false;                                                                           //읽기 전용 해제
            _file.Delete();                                                                                     //삭제
        }

        _file = new FileInfo(@"Assets/Resources/Voice" + _voiceDirectoryPath + "/" + gameObject.name + ".meta"); //meta 파일 삭제

        if (_file.Exists)                                                                                        //파일 존재하면
        {
            _file.IsReadOnly = false;                                                                            //읽기 전용 해제
            _file.Delete();                                                                                      //삭제
        }

#if UNITY_EDITOR
        AssetDatabase.Refresh(); //Asset 갱신
        Destroy(gameObject);     //현재 Content 삭제
#endif
        _startDBController.DeleteFile(_key, gameObject.name);
    }