Ejemplo n.º 1
0
    public void Button()
    {
        load.PlayForward();
        mengban.PlayForward();
        GameObject[] sno1;
        string       txt   = "";
        Text         names = GameObject.Find("AudioPanel").GetComponent <MakerAudioPlayer>().audioName;
        AudioClip    clip  = GameObject.Find("AudioPanel").GetComponent <MakerAudioPlayer>().audioSource.clip;

        sno1 = GameObject.FindGameObjectsWithTag("Fire");
        foreach (GameObject item in sno1)
        {
            int type = -1;
            if (item.name == "Roadblock(Clone)")
            {
                type = 1;
            }
            else if (item.name == "Plane(Clone)")
            {
                type = 2;
            }
            else if (item.name == "EnemyAll(Clone)")
            {
                type = 3;
            }
            float  a   = item.transform.localPosition.x;
            string str = type.ToString() + " " + a.ToString();
            if (type != -1)
            {
                txt += str + "\n";
            }
        }
        string dir = "./song/" + names.text;

        if (!Directory.Exists(dir))//如果不存在就创建 dir 文件夹
        {
            Directory.CreateDirectory(dir);
        }
        StreamWriter F = new StreamWriter(dir + "/" + names.text + ".txt", false);

        F.Write(txt);
        F.Close();
        byte[]     bytes = AudioClipExtension.EncodeToWAV(clip);
        FileStream fs    = new FileStream(dir + "/" + names.text + ".wav", FileMode.Create);//新建文件

        fs.Write(bytes, 0, bytes.Length);
        fs.Flush();
        fs.Close();
    }
Ejemplo n.º 2
0
    void Update()
    {
        if (a - DateTimeKind.Local > 10)
        {
            char[] eoc = { 0x45, 0x4f, 0x53 };
            Microphone.End(null);
        }
        float l = micIn.loudness;

        //Debug.Log(l);
        // print(l);
        if (l > 0.5)
        {
            // print(l);
            //Vector3 scale = new Vector3(l, l, l);
            //GameObject newObject = (GameObject)Instantiate(objectToSpawn, this.transform.position, Quaternion.identity);
            //newObject.transform.localScale += scale;


            _Wav = AudioClipExtension.EncodeToWAV(micIn.audio.clip);

            Debug.Log("Requirments Hit");
        }
    }