예제 #1
0
 // print tombol untuk save profile pemain
 private void SaveProfile(string key)
 {
     if (GamePrefs.isVoiceUsed)
     {
         if (GUI.Button(new Rect(500, 630, 300, 50), "Save Voice"))
         {
             //AudioWordDetection.SaveProfiles(new FileInfo(key));
             AudioWordDetection.SaveProfilesPrefs(key);
         }
     }
 }
    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();
    }