예제 #1
0
    private void LoadProfile(string key)
    {
        if (        //AudioWordDetection.LoadProfiles(new FileInfo(key)) //||
            AudioWordDetection.LoadProfilesPrefs(key))
        //)
        {
            for (int wordIndex = 0; wordIndex < AudioWordDetection.Words.Count; ++wordIndex)
            {
                WordDetails details = AudioWordDetection.Words[wordIndex];

                if (null != details.Wave &&
                    details.Wave.Length > 0)
                {
                    if (null == details.Audio)
                    {
                        details.Audio = AudioClip.Create(string.Empty, details.Wave.Length, 1, Mic.SampleRate, false,
                                                         false);
                    }
                    details.Audio.SetData(details.Wave, 0);
                    audio.loop = false;
                    audio.mute = false;
                }

                SetupWordProfile(details, false);
            }
        }
    }
    protected void DisplayProfileLoadSave(string key)
    {
        GUILayout.BeginHorizontal();

        GUILayout.Label(string.Empty, GUILayout.Width(150));
        GUILayout.Label("Profiles:");
        GUILayout.Label(string.Empty, GUILayout.Width(30));
        if (GUILayout.Button("Load", GUILayout.MinHeight(40)))
        {
            if (            //AudioWordDetection.LoadProfiles(new FileInfo(key)) //||
                AudioWordDetection.LoadProfilesPrefs(key))
            //)
            {
                for (int wordIndex = 0; wordIndex < AudioWordDetection.Words.Count; ++wordIndex)
                {
                    WordDetails details = AudioWordDetection.Words[wordIndex];

                    if (null != details.Wave &&
                        details.Wave.Length > 0)
                    {
                        if (null == details.Audio)
                        {
                            details.Audio = AudioClip.Create(string.Empty, details.Wave.Length, 1, _Mic.SampleRate, false,
                                                             false);
                        }
                        details.Audio.SetData(details.Wave, 0);
                        GetComponent <AudioSource>().loop = false;
                        GetComponent <AudioSource>().mute = false;
                    }

                    SetupWordProfile(details, false);
                }
            }
        }
        GUILayout.Label(string.Empty, GUILayout.Width(30));
        if (GUILayout.Button("Save", GUILayout.MinHeight(40)))
        {
            //AudioWordDetection.SaveProfiles(new FileInfo(key));
            AudioWordDetection.SaveProfilesPrefs(key);
        }

        GUILayout.EndHorizontal();
    }