For the life of me I can not get AudioTo or AudioFrom to work. Can someone help me with the code. I’m trying to just have it be at volume 0 for now and will adjust the volume later. This is one of many audio sources on this game object.
Sorry for not being as specific, brain freeze and I"m just learning iTween (but I love it so far).
var Music_menu_background:AudioClip;
I put the audio clip in that variable in the Inspector. And have an audio source on the game object that has the audio clip on it. I am trying to turn the volume down when going between menu’s in the same scene.
Then that bit of code…
iTween.AudioTo(gameObject, {“audiosource”:Music_menu_background, “volume”: 0.0});
… is down under a function when you switch menu’s to change the volume of that clip.
The parameter “audiosource” takes the type AudioSource, but you are supplying a AudioClip.
You need to actually supply the audio source as opposed to the audioclip. So:
public var Music_menu_background:AudioSource;
Then in the inspector drag the gameObject with the audiosource onto the Music_menu_background variable. So if the audiosource is on the camera - drag the camera onto the Music_menu_background variable in the inspector. The iTween function actually changes the volume of the audiosource not the clip itself.
The iTween documentation ( iTween for Unity by Bob Berkebile (pixelplacement) ) has a list of properties for each function. Generally when you get an InvalidCastException with iTween it’s because you’re passing the wrong type.