Пример #1
0
        private void InitializeKeywordRecognizer()
        {
            //ManualList m_ManualList = SpeechInputManager2.Instance.ManualList;

            string manualJson = "";
            var    textAsset  = Resources.Load("Manual") as TextAsset;

            manualJson = textAsset.text;
            ManualList m_ManualList = JsonUtility.FromJson <ManualList>(manualJson);

            m_SpeechCommandsArray = Commands;
            foreach (var val in m_ManualList.list[0].manual[0].operation)
            {
                SpeechCommands m_SpeechCommands = new SpeechCommands(val.kaiheikikana, KeyCode.B, MixedRealityInputAction.None, null);
                Array.Resize(ref m_SpeechCommandsArray, m_SpeechCommandsArray.Length + 1);
                m_SpeechCommandsArray[m_SpeechCommandsArray.Length - 1] = m_SpeechCommands;
            }

            if (!Application.isPlaying ||
                (m_SpeechCommandsArray == null) ||
                (m_SpeechCommandsArray.Length == 0) ||
                InputSystemProfile == null ||
                keywordRecognizer != null
                )
            {
                return;
            }

            InputSource = Service?.RequestNewGenericInputSource("Windows Speech Input Source", sourceType: InputSourceType.Voice);

            var newKeywords = new string[m_SpeechCommandsArray.Length];

            for (int i = 0; i < m_SpeechCommandsArray.Length; i++)
            {
                newKeywords[i] = m_SpeechCommandsArray[i].LocalizedKeyword;
            }

            RecognitionConfidenceLevel = InputSystemProfile.SpeechCommandsProfile.SpeechRecognitionConfidenceLevel;

            try
            {
                keywordRecognizer = new KeywordRecognizer(newKeywords, (ConfidenceLevel)RecognitionConfidenceLevel);
            }
            catch (Exception ex)
            {
                Debug.LogWarning($"Failed to start keyword recognizer. Are microphone permissions granted? Exception: {ex}");
                keywordRecognizer = null;
                return;
            }

            keywordRecognizer.OnPhraseRecognized += KeywordRecognizer_OnPhraseRecognized;
        }
        private List <int> MakeMasterIdList()
        {
            List <int> temp = new List <int>();

            ManualList = GrandcypherClient.Current.WeaponHooker.WeaponLists.Where(x => x.IsManual).ToList();
            if (GrandcypherClient.Current.WeaponHooker.MainWeapon.IsManual)
            {
                ManualList.Add(GrandcypherClient.Current.WeaponHooker.MainWeapon);
            }
            var t = RemoveDuplicateValue(ManualList);

            foreach (var item in t)
            {
                temp.Add(item.MasterId);
            }

            return(temp);
        }
    public void LoadManualJsonData()
    {
        string manualJson = "";

#if !UNITY_EDITOR
        Task.Run(async() =>
        {
            UnityEngine.WSA.Application.InvokeOnAppThread(() =>
            {
                m_debugLogManager.DebugLogTextWrite("MyDebug:*****************1");
            }, false);

            var file = await KnownFolders.DocumentsLibrary.GetFileAsync("Manual.txt");
            //var file = await KnownFolders.DocumentsLibrary.GetFileAsync("City.txt");

            UnityEngine.WSA.Application.InvokeOnAppThread(() =>
            {
                m_debugLogManager.DebugLogTextWrite("MyDebug:*****************2");
            }, false);

            manualJson = await FileIO.ReadTextAsync(file);

            manualList = JsonUtility.FromJson <ManualList>(manualJson);

            UnityEngine.WSA.Application.InvokeOnAppThread(() =>
            {
                m_debugLogManager.DebugLogTextWrite("MyDebug:*****************3");

                m_debugLogManager.DebugLogTextWrite("MyDebug:" + manualList.list[0].manual[0].operation.Count);
                m_debugLogManager.DebugLogTextWrite("MyDebug:" + manualList.list[0].manual[0].operation[0].kaiheiki);
                //m_debugLogManager.DebugLogTextWrite(manualJson);
            }, false);
        });
#else
        var textAsset = Resources.Load("Manual") as TextAsset;
        manualJson = textAsset.text;
        manualList = JsonUtility.FromJson <ManualList>(manualJson);

        m_debugLogManager.DebugLogTextWrite("MyDebug:" + manualList.list[0].manual[0].operation.Count);
        m_debugLogManager.DebugLogTextWrite("MyDebug:" + manualList.list[0].manual[0].operation[0].kaiheiki);
        //m_debugLogManager.DebugLogTextWrite(manualJson);
#endif
    }