// Update is called once per frame
    void Update()
    {
        //Debug.Log(txt);
        txt = _speech.Str;

        //Debug.Log(txt);


        if (isDrag)
        {
            Vector3 pos;
            currentInputSource.TryGetPosition(id, out pos);
            Vector3    directionToTarget = Camera.main.transform.position - pos;
            Quaternion qua;
            currentInputSource.TryGetOrientation(id, out qua);
            qua = Quaternion.LookRotation(-directionToTarget);

            drawtmp.transform.position = pos;

            //音声認識が動作してるか確認
            //if (m_DictationRecognizer.Status == SpeechSystemStatus.Running)
            //{
            //    bbb = "Running";
            //    errortex.text = bbb;
            //    errortex.color = Color.green;
            //    //Debug.Log("Running");
            //}

            //音声認識が動作してるか確認
            if (_speech.Status == speech.State.Stop)
            {
                bbb            = "Running";
                errortex.text  = bbb;
                errortex.color = Color.green;

                _speech.StartRecordButtonOnClickHandler();
                //Debug.Log("Running");
            }

            if (tmppos == null && tmprot == null)
            {
                poss.Add(pos);
                rots.Add(qua);
                tmppos = pos;
                tmprot = qua;
            }
            else if (((Vector3)tmppos - pos).sqrMagnitude > 0.001)
            {
                //Debug.Log("hoge");
                poss.Add(pos);
                rots.Add(qua);
                tmppos = pos;
                tmprot = qua;
            }
        }
        else
        {
            if (_speech.Status == speech.State.Recording)
            {
                _speech.StopRecordButtonOnClickHandler();
            }

            bbb            = "Missing";
            errortex.text  = bbb;
            errortex.color = Color.red;
            //Debug.Log(txt);
            //if (txt != "")
            //{
            //    foreach (char c in txt)
            //    {
            //        chars.Add(c);
            //    }
            //    txt = "";
            //}

            //// 話した内容を一文字ずつ表示
            //if (chars.Count != 0)
            //{
            //    int tmpcount = chars.Count;
            //    for (int i = 0; i < poss.Count; i++)
            //    {
            //        if (tmpcount > 0)
            //        {
            //            GameObject tmp = GameObject.Instantiate(original);
            //            TextMesh tex = tmp.GetComponent<TextMesh>();
            //            String tmptxt;
            //            tmptxt = chars[i].ToString();
            //            tex.text = tmptxt;
            //            tmp.transform.position = poss[i];
            //            tmp.transform.rotation = rots[i];
            //            DontDestroyOnLoad(tmp);

            //            tmpcount = tmpcount - 1;
            //            CustomMessages.Instance.SendVoiceLine(poss[i], rots[i], tmptxt);
            //        }
            //    }
            //}
            //ResetObj();

            // 音声が取得できなかった場合,一定時間後に保持した座標を消す
            if (_speech.Status == speech.State.Analyzing)
            {
                StartCoroutine("shokika");
            }

            ResetDrawObj();
        }

        if (txt != "")
        {
            foreach (char c in txt)
            {
                chars.Add(c);
            }

            // 話した内容を一文字ずつ表示
            if (chars.Count != 0)
            {
                int tmpcount = chars.Count;
                for (int i = 0; i < poss.Count; i++)
                {
                    if (tmpcount > 0)
                    {
                        GameObject tmp = GameObject.Instantiate(original);
                        TextMesh   tex = tmp.GetComponent <TextMesh>();
                        String     tmptxt;
                        tmptxt   = chars[i].ToString();
                        tex.text = tmptxt;
                        tmp.transform.position = poss[i];
                        tmp.transform.rotation = rots[i];
                        voiceTextList.Add(tmp);
                        DontDestroyOnLoad(tmp);

                        byte[] bytesData = new byte[1024];
                        bytesData = System.Text.Encoding.UTF8.GetBytes(tmptxt);
                        tmpcount  = tmpcount - 1;
                        CustomMessages.Instance.SendVoiceLine(poss[i], rots[i], bytesData);
                    }
                }
            }
            ResetObj();
        }


        //if (txt != null)
        //{
        //    bbb = "Success";
        //    errortex.text = bbb;
        //    errortex.color = Color.blue;
        //}

        RaycastHit hitInfo;

        hit = Physics.Raycast(Camera.main.transform.position,
                              Camera.main.transform.forward,
                              out hitInfo,
                              20f);

        if (hit && hitInfo.collider.tag == "DummyAnchor")
        {
            returnToMenuFlag = 1;
            //Debug.Log(hitInfo.collider.tag);
        }
    }