LineCount() public method

This will return how many lines there are currently stored
public LineCount ( ) : int
return int
Ejemplo n.º 1
0
    //public static EasyVoiceSettings.AudioImportSettings.SampleRate SampleRate(AudioSampleRateSetting sampleRate)
    //{
    //    switch (sampleRate)
    //    {
    //        case AudioSampleRateSetting.PreserveSampleRate:
    //            return EasyVoiceSettings.AudioImportSettings.SampleRate.PreserveSampleRate;
    //        case AudioSampleRateSetting.OptimizeSampleRate:
    //            return EasyVoiceSettings.AudioImportSettings.SampleRate.OptimizeSampleRate;
    //        case AudioSampleRateSetting.OverrideSampleRate:
    //            return EasyVoiceSettings.AudioImportSettings.SampleRate.OverrideSampleRate;
    //        default:
    //            return EasyVoiceSettings.AudioImportSettings.SampleRate.PreserveSampleRate; // Unity has a new value?
    //    }
    //}

    public static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
    {
        // This will make sure that if any changed assets match our lines, then these lines will have their clip/file name re-checked for issues (or no more issues)

        if (EasyVoiceSettings.instance != null && EasyVoiceSettings.instance.data != null) // we are not yet initialized?
        {
            EasyVoiceDataAsset data = EasyVoiceSettings.instance.data;
            for (int lineIndex = 0; lineIndex < data.LineCount(); lineIndex++)
            {
                //string assetFileName, fullFileName;
                //EasyVoiceClipCreator.GenerateFullFileName(lineIndex, out assetFileName, out fullFileName);
                //if ((deletedAssets != null && deletedAssets.Contains(assetFileName)) ||
                //    (movedAssets != null && movedAssets.Contains(assetFileName)) ||
                //    (importedAssets != null && importedAssets.Contains(assetFileName)) ||
                //    (movedFromAssetPaths != null && movedFromAssetPaths.Contains(assetFileName)))
                //{ -- WE CAN'T RELY ON THIS, IT DOESN'T TELL US WHAT THE FILE NAME *WAS* (and keeping this cached is an overkill imo)
                EasyVoiceIssueChecker.VerifyFileNameOrClip(lineIndex);
                //    break;
                //}
            }
        }
    }
Ejemplo n.º 2
0
    private static void VerifyFileNameOrClip(int index, bool allowFurtherCalls)
    {
        verifyCount++;

        EasyVoiceDataAsset data = EasyVoiceSettings.instance.data; // readability

        data.SetIssue(index, LineIssue.badFileName, !ValidFileName(data.GetFileName(index)));

        // CLear all issues that we can possibly set in the loops below
        data.SetIssue(index, LineIssue.duplicateBaseFileName, false);
        data.SetIssue(index, LineIssue.duplicateAssetFileName, false);
        data.SetIssue(index, LineIssue.clashingExistingAsset, false);
        data.SetIssue(index, LineIssue.duplicateClipReference, false);

        //Debug.Log("Clearing line " + index + " file name or clip issues");

        AudioClip ourClip = data.GetClip(index);

        string ourAssetFileName, ourFullFileName;

        EasyVoiceClipCreator.GenerateFullFileName(index, out ourAssetFileName, out ourFullFileName);

        if (ourClip == null)
        {
            string ourFileName = data.GetFileNameOrDefault(index);

            for (int otherIndex = 0; otherIndex < data.LineCount(); otherIndex++)
            {
                if (otherIndex == index)
                {
                    continue;
                }

                if (data.GetClip(otherIndex) == null)
                {
                    // Check for duplicate file names -- another line has the same file name as us
                    if (ourFileName == data.GetFileNameOrDefault(otherIndex))
                    {
                        data.SetIssue(index, LineIssue.duplicateBaseFileName, true);
                        if (allowFurtherCalls)
                        {
                            // Recheck the other file as well now, because we probably just clashed it
                            VerifyFileNameOrClip(otherIndex, false);
                        }
                    }
                    else
                    {
                        // Recheck existing lines with duplicate issue, in case we were the one causing it
                        if (allowFurtherCalls)
                        {
                            if (data.HasIssue(otherIndex, LineIssue.duplicateBaseFileName))
                            {
                                VerifyFileNameOrClip(otherIndex, false);
                            }
                        }
                    }
                }
                else
                {
                    string otherAssetFileName, otherFullFileName;
                    EasyVoiceClipCreator.GenerateFullFileName(otherIndex, out otherAssetFileName, out otherFullFileName); // TODO: cache?

                    // Check for clashing clip names -- another line has a clip name+path the same as our potential file path
                    if (ourAssetFileName == otherAssetFileName)
                    {
                        data.SetIssue(index, LineIssue.duplicateAssetFileName, true);
                        if (allowFurtherCalls)
                        {
                            // Recheck the other file as well now, because we probably just clashed it
                            VerifyFileNameOrClip(otherIndex, false);
                        }
                    }
                    else
                    {
                        // Recheck existing lines with clashing file name issue, in case we were the one causing it
                        if (allowFurtherCalls)
                        {
                            if (data.HasIssue(otherIndex, LineIssue.duplicateAssetFileName))
                            {
                                VerifyFileNameOrClip(otherIndex, false);
                            }
                        }
                    }
                }
            }

            if (!data.HasIssue(index, LineIssue.duplicateAssetFileName)) // below issue is implied if already clashing another line with that asset, performance
            {
                // Check for clashing existing assets -- an asset already exists at the path that "our" asset will potentially be created at
                Object foundAsset = (Object)AssetDatabase.LoadAssetAtPath(ourAssetFileName, typeof(Object));
                if (foundAsset != null)
                {
                    data.SetIssue(index, LineIssue.clashingExistingAsset, true);
                }
            }
        }
        else
        {
            for (int otherIndex = 0; otherIndex < data.LineCount(); otherIndex++)
            {
                if (otherIndex == index)
                {
                    continue;
                }

                if (data.GetClip(otherIndex) != null)
                {
                    // Check for duplicate clip references -- another line has the same clip as we do
                    if (ourClip == data.GetClip(otherIndex))
                    {
                        data.SetIssue(index, LineIssue.duplicateClipReference, true);
                        if (allowFurtherCalls)
                        {
                            // Recheck the other file as well now, because we probably just clashed it
                            VerifyFileNameOrClip(otherIndex, false);
                        }
                    }
                    else
                    {
                        // Recheck existing lines with duplicate clip issue, in case we were the one causing it
                        if (allowFurtherCalls)
                        {
                            if (data.HasIssue(otherIndex, LineIssue.duplicateClipReference))
                            {
                                VerifyFileNameOrClip(otherIndex, false);
                            }
                        }
                    }
                }
                else
                {
                    // Check for clashing clip names -- another line has a the same potential file path as our clip name+path

                    string otherAssetFileName, otherFullFileName;
                    EasyVoiceClipCreator.GenerateFullFileName(otherIndex, out otherAssetFileName, out otherFullFileName); // TODO: cache?

                    if (ourAssetFileName == otherAssetFileName)
                    {
                        data.SetIssue(index, LineIssue.duplicateAssetFileName, true);
                        if (allowFurtherCalls)
                        {
                            // Recheck the other file as well now, because we probably just clashed it
                            VerifyFileNameOrClip(otherIndex, false);
                        }
                    }
                    else
                    {
                        // Recheck existing lines with clashing file name issue, in case we were the one causing it
                        if (allowFurtherCalls)
                        {
                            if (data.HasIssue(otherIndex, LineIssue.duplicateAssetFileName))
                            {
                                VerifyFileNameOrClip(otherIndex, false);
                            }
                        }
                    }
                }
            }
        }
    }