Mic record on button click
I'm trying to get the mic to record when I press on a button (onClick). The mic can capture and playback if I put the code into
function Start()
Could anyone tell me what I'm doing wrong to make this work with an onClick button action?
#pragma strict
static var reco : AudioClip;
function onClick() {
var aud = GetComponent.<AudioSource>();
reco = Microphone.Start("Built-in Microphone", false, 2, 44100);
aud.clip = reco;
aud.Play()
}
Through someone's suggestion, I debugged and found that the microphone was indeed recording, just that it didn't playback from the same function call.
Would anyone happen to know how I can playback this microphone recording from another script during the same execution run? I don't need the recording to be saved, just to persist from scene to scene and to be able to playback from different scripts.
Answer by wsgb · Nov 12, 2015 at 01:07 PM
Following up on my comment above, this is the solution to my follow-up question: http://answers.unity3d.com/questions/10857/how-can-i-access-other-scripts-and-their-functions.html
I've switched over to using this scripting ins$$anonymous$$d of the chosen answer. http://docs.unity3d.com/410/Documentation/ScriptReference/index.Accessing_Other_Game_Objects.html
Your answer
Follow this Question
Related Questions
Problem with MIC process for Windows Store platform 0 Answers
Create a new audioclip from GetData result in a muted sound 0 Answers
Difficult Question - Multitrack recoring using microphone issue 0 Answers
Why won't my second Audio Source play? 0 Answers
Microphone.start(), need lengthsec unfixed value, is possible? 1 Answer