SetCallback() public method

public SetCallback ( Action cb ) : void
cb Action
return void
    void Update()
    {
        // main audio analysis
        GetMultibandAmplitude();

        // select audio input device
        if (Input.GetKeyDown(KeyCode.I))
        {
            if (micSelector == null)
            {
                micSelector = gameObject.AddComponent <SelectInputGUI>();
                micSelector.SetCallback(SetInputDevice);
            }
            else
            {
                Destroy(micSelector);
                micSelector = null;
            }
        }

        if (source.mute == listen)
        {
            source.mute = !listen;
        }
    }
Esempio n. 2
0
    void Update()
    {
        if(!mixer)
        {
            Debug.LogError("no mixer found on audio analyzer object: mixer must be set in inspector");
            return;
        }
        // main audio analysis
        GetMultibandAmplitude();

        // select audio input device
        if (Input.GetKeyDown(inputSelectionKey))
        {
            if (micSelector == null)
            {
                micSelector = gameObject.AddComponent<SelectInputGUI>();
                micSelector.SetCallback(SetInputDevice);
            }
            else
            {
                Destroy(micSelector);
                micSelector = null;
            }
        }

        // unity will no longer process audio on a muted AudioSource
        // the mixer must be muted instead
        if(listen == isListening)
        {
            isListening = !listen;
            mixer.SetFloat("InputVolume", listen ? 0f : -80f);
        }
    }