IsDefaultFolderValid() 공개 메소드

public IsDefaultFolderValid ( ) : bool
리턴 bool
예제 #1
0
    public static CreateFilesCheckResult CreateFilesPreCheck(EasyVoiceSettings settings)
    {
        if (!settings.IsDefaultFolderValid())
            return CreateFilesCheckResult.badDefaultFolder;

        string fullPath = settings.GetFullClipDefaultPath();
        if (!Directory.Exists(fullPath))
            return CreateFilesCheckResult.missingDefaultFolder;

        if (!settings.querier.VerifyApp())
            return CreateFilesCheckResult.querierFailedToVerifyApp;

        return CreateFilesCheckResult.ok; // no apparent problems
    }
예제 #2
0
    public static CreateFilesCheckResult CreateFilesPreCheck(EasyVoiceSettings settings)
    {
        if (!settings.IsDefaultFolderValid())
        {
            return(CreateFilesCheckResult.badDefaultFolder);
        }

        string fullPath = settings.GetFullClipDefaultPath();

        if (!Directory.Exists(fullPath))
        {
            return(CreateFilesCheckResult.missingDefaultFolder);
        }

        if (!settings.querier.VerifyApp())
        {
            return(CreateFilesCheckResult.querierFailedToVerifyApp);
        }

        return(CreateFilesCheckResult.ok); // no apparent problems
    }
예제 #3
0
    public static ImportResult ImportData(string fileName, EasyVoiceSettings settings, bool append)
    {
        try
        {
            if (!File.Exists(fileName))
            {
                Debug.LogWarning("EasyVoice.ImportData tried to open the file returned by Unity's dialog, but such file doesn't appear to exist: \"" + fileName + "\"!");
                return ImportResult.fail;
            }

            FileStream fileStream = new FileStream(fileName, FileMode.Open, FileAccess.Read);
            StreamReader streamReader = new StreamReader(fileStream, settings.exportCSVFileEncodingUTF8 ? Encoding.Unicode : Encoding.ASCII);

            string header = streamReader.ReadLine();
            List<string> headerSplit = SplitLine(header);
            if (headerSplit == null || headerSplit.Count != 6 || headerSplit[0] != "ID" || headerSplit[1] != "Group" || headerSplit[2] != "Status" || headerSplit[3] != "Speaker" || headerSplit[4] != "Text" || headerSplit[5] != "File name")
            {
                Debug.LogWarning("EasyVoice.ImportData opened the CSV the file, but the header syntax did not match the expected format!");
                return ImportResult.fail;
            }

            List<int> tempIds = new List<int>();
            List<string> tempGroups = new List<string>();
            List<byte> tempStatuses = new List<byte>();
            List<string> tempSpeakerNames = new List<string>();
            List<string> tempSpeechTexts = new List<string>();
            List<string> tempFileNames = new List<string>();
            List<LineIssue> tempIssues = new List<LineIssue>();

            while (!streamReader.EndOfStream)
            {
                string line = streamReader.ReadLine();
                List<string> splitLine = SplitLine(line);
                //Debug.Log(splitLine);
                if (splitLine != null && splitLine.Count == 6)
                {
                    int id;
                    if (!int.TryParse(splitLine[0], out id))
                    {
                        Debug.LogWarning("EasyVoice.ImportData opened the CSV the file, but an encountered id field syntax did not match the expected format!");
                        return ImportResult.fail;
                    }
                    tempIds.Add(id);
                    tempGroups.Add(splitLine[3]);
                    byte status;
                    if (!byte.TryParse(splitLine[2], out status))
                    {
                        Debug.LogWarning("EasyVoice.ImportData opened the CSV the file, but an encountered status field syntax did not match the expected format!");
                        return ImportResult.fail;
                    }
                    tempStatuses.Add(status);
                    tempSpeakerNames.Add(splitLine[3]);
                    tempSpeechTexts.Add(splitLine[4]);
                    tempFileNames.Add(splitLine[5]);
                    tempIssues.Add(0);
                }
                else
                {
                    Debug.LogWarning("EasyVoice.ImportData opened the CSV the file, but an encountered line syntax did not match the expected format!");
                    return ImportResult.fail;
                }
            }

            streamReader.Close();
            fileStream.Close();

            if (!append)
                settings.data.DeleteAllLines();

            lastImportStartingLineCount = settings.data.LineCount();

            bool defaultFolderValid = settings.IsDefaultFolderValid(); // so we don't check this too many times
            bool clipFound = false;

            for (int i = 0; i < tempSpeakerNames.Count; i++)
            {
                settings.data.AddNewLine(tempIds[i], tempGroups[i], tempStatuses[i], tempSpeakerNames[i], tempSpeechTexts[i], tempFileNames[i], tempIssues[i]);

                // If we need to find a clip (haven't found one yet) and also settings are valid to do this check
                if (!clipFound && defaultFolderValid)
                {
                    string assetFileName, fullFileName;
                    EasyVoiceClipCreator.GenerateFullFileName(i, out assetFileName, out fullFileName);
                    AudioClip foundClip = (AudioClip)AssetDatabase.LoadAssetAtPath(assetFileName, typeof(AudioClip));
                    if (foundClip != null)
                        clipFound = true;
                }
            }

            EasyVoiceIssueChecker.CheckAllLineIssues(); // this will get called again after linking clips, but we don't know if user will decide to do this yet

            return clipFound ? ImportResult.matchingClipsFound : ImportResult.okay;
        }
        catch (Exception e)
        {
            Debug.LogError("EasyVoice.ImportData encountered an error: " + e);
            return ImportResult.fail;
        }
    }
예제 #4
0
    public static ImportResult ImportData(string fileName, EasyVoiceSettings settings, bool append)
    {
        try
        {
            if (!File.Exists(fileName))
            {
                Debug.LogWarning("EasyVoice.ImportData tried to open the file returned by Unity's dialog, but such file doesn't appear to exist: \"" + fileName + "\"!");
                return(ImportResult.fail);
            }

            FileStream   fileStream   = new FileStream(fileName, FileMode.Open, FileAccess.Read);
            StreamReader streamReader = new StreamReader(fileStream, settings.exportCSVFileEncodingUTF8 ? Encoding.Unicode : Encoding.ASCII);

            string        header      = streamReader.ReadLine();
            List <string> headerSplit = SplitLine(header);
            if (headerSplit == null || headerSplit.Count != 6 || headerSplit[0] != "ID" || headerSplit[1] != "Group" || headerSplit[2] != "Status" || headerSplit[3] != "Speaker" || headerSplit[4] != "Text" || headerSplit[5] != "File name")
            {
                Debug.LogWarning("EasyVoice.ImportData opened the CSV the file, but the header syntax did not match the expected format!");
                return(ImportResult.fail);
            }

            List <int>       tempIds          = new List <int>();
            List <string>    tempGroups       = new List <string>();
            List <byte>      tempStatuses     = new List <byte>();
            List <string>    tempSpeakerNames = new List <string>();
            List <string>    tempSpeechTexts  = new List <string>();
            List <string>    tempFileNames    = new List <string>();
            List <LineIssue> tempIssues       = new List <LineIssue>();

            while (!streamReader.EndOfStream)
            {
                string        line      = streamReader.ReadLine();
                List <string> splitLine = SplitLine(line);
                //Debug.Log(splitLine);
                if (splitLine != null && splitLine.Count == 6)
                {
                    int id;
                    if (!int.TryParse(splitLine[0], out id))
                    {
                        Debug.LogWarning("EasyVoice.ImportData opened the CSV the file, but an encountered id field syntax did not match the expected format!");
                        return(ImportResult.fail);
                    }
                    tempIds.Add(id);
                    tempGroups.Add(splitLine[3]);
                    byte status;
                    if (!byte.TryParse(splitLine[2], out status))
                    {
                        Debug.LogWarning("EasyVoice.ImportData opened the CSV the file, but an encountered status field syntax did not match the expected format!");
                        return(ImportResult.fail);
                    }
                    tempStatuses.Add(status);
                    tempSpeakerNames.Add(splitLine[3]);
                    tempSpeechTexts.Add(splitLine[4]);
                    tempFileNames.Add(splitLine[5]);
                    tempIssues.Add(0);
                }
                else
                {
                    Debug.LogWarning("EasyVoice.ImportData opened the CSV the file, but an encountered line syntax did not match the expected format!");
                    return(ImportResult.fail);
                }
            }

            streamReader.Close();
            fileStream.Close();

            if (!append)
            {
                settings.data.DeleteAllLines();
            }

            lastImportStartingLineCount = settings.data.LineCount();

            bool defaultFolderValid = settings.IsDefaultFolderValid(); // so we don't check this too many times
            bool clipFound          = false;

            for (int i = 0; i < tempSpeakerNames.Count; i++)
            {
                settings.data.AddNewLine(tempIds[i], tempGroups[i], tempStatuses[i], tempSpeakerNames[i], tempSpeechTexts[i], tempFileNames[i], tempIssues[i]);

                // If we need to find a clip (haven't found one yet) and also settings are valid to do this check
                if (!clipFound && defaultFolderValid)
                {
                    string assetFileName, fullFileName;
                    EasyVoiceClipCreator.GenerateFullFileName(i, out assetFileName, out fullFileName);
                    AudioClip foundClip = (AudioClip)AssetDatabase.LoadAssetAtPath(assetFileName, typeof(AudioClip));
                    if (foundClip != null)
                    {
                        clipFound = true;
                    }
                }
            }

            EasyVoiceIssueChecker.CheckAllLineIssues(); // this will get called again after linking clips, but we don't know if user will decide to do this yet

            return(clipFound ? ImportResult.matchingClipsFound : ImportResult.okay);
        }
        catch (Exception e)
        {
            Debug.LogError("EasyVoice.ImportData encountered an error: " + e);
            return(ImportResult.fail);
        }
    }