First, basic introduction; second, basic attributes
Original address: http://blog.csdn.net/dingkun520wy/article/details/50826033
First, the basic introduction
Audioto: Changes the volume and pitch of the sound to the specified value.
Audiofrom: Changes the volume and pitch of the sound from the given value to the original value;
Audioupdate: Similar to Audioto, called in the Update () method or in a looping environment. Provides an environment for changing attribute values per frame. Not dependent on Easrtype
Stab: Play AudioClip once, you can not manually load Audiosource components
Second, the basic attributes
Basic attributes are simpler and directly on the code
First of all, Audioto.
[CSharp]View PlainCopy
- void Start () {
- //Play the Sound object
- Audiosource Tempsource = gameobject.addcomponent<audiosource> ();
- Tempsource.loop = true;
- Tempsource.clip = Soundend;
- Tempsource.volume = 1;
- Tempsource.play ();
- //Key-value pairs the parameters used to save the Itween
- Hashtable args = new Hashtable ();
- //Sound
- Args. ADD ("Audiosource", Tempsource);
- //Volume
- Args. ADD ("volume", 0);
- //Tone
- Args. ADD ("pitch", 0);
- //Time of Change
- Args. ADD ("Time", 10f);
- //Delay Execution Time
- Args. ADD ("delay", 0.1f);
- //Here is the set type, Itween type and many kinds, in the source of enumeration Easetype
- Args. ADD ("Easetype", ITween.EaseType.easeInOutExpo);
- //Three loop type none Loop Pingpong (General loop back and forth)
- //args. ADD ("Looptype", "none");
- //args. ADD ("Looptype", "loop");
- Args. ADD ("Looptype", ITween.LoopType.pingPong);
- //Handles events during playback.
- the Animationstart method is called when playback starts, and 5.0 indicates its arguments
- Args. ADD ("OnStart", "Animationstart");
- Args. ADD ("Onstartparams", 5.0f);
- //Set the object to accept the method, the default is self-acceptance, here can also be changed to another object to accept,
- //Then you have to implement the Animationstart method in the script that receives the object.
- Args. ADD ("Onstarttarget", gameobject);
- //Play at the end of the call, parameters and similar above
- Args. ADD ("OnComplete", "Animationend");
- Args. ADD ("Oncompleteparams", "End");
- Args. ADD ("Oncompletetarget", gameobject);
- //play in call, parameters and similar above
- Args. ADD ("OnUpdate", "animationupdate");
- Args. ADD ("Onupdatetarget", gameobject);
- Args. ADD ("Onupdateparams", true);
- Itween.audioto (Btnbegin, args);
- }
- //The animation is called at the start
- void Animationstart (float f)
- {
- Debug.Log ("Start:" + f);
- }
- //At the end of the animation call
- void Animationend (string f)
- {
- Debug.Log ("End:" + f);
- }
- //Call in animation
- void Animationupdate (bool f)
- {
- Debug.Log ("UPDATE:" + f);
- }
And then the stab code.
[CSharp]View PlainCopy
- void Start () {
- //Key-value pairs the parameters used to save the Itween
- Hashtable Stabargs = new Hashtable ();
- //audio source to play
- Stabargs.add ("AudioClip", soundtanover);
- //Play the volume
- Stabargs.add ("Volume", 1);
- //Play to the specified Audiosource (can default)
- //audiosource Tempsource = gameobject.addcomponent<audiosource> ();
- //stabargs.add ("Audiosource", Tempsource);
- //Set the tone of the sound
- Stabargs.add ("pitch", 1);
- //Delay play
- Stabargs.add ("delay", 0);
- //Handles events during playback.
- the Animationstart method is called when playback starts, and 5.0 indicates its arguments
- Stabargs.add ("OnStart", "Animationstart");
- Stabargs.add ("Onstartparams", 5.0f);
- //Set the object to accept the method, the default is self-acceptance, here can also be changed to another object to accept,
- //Then you have to implement the Animationstart method in the script that receives the object.
- Stabargs.add ("Onstarttarget", gameobject);
- //Play at the end of the call, parameters and similar above
- Stabargs.add ("OnComplete", "Animationend");
- Stabargs.add ("Oncompleteparams", "End");
- Stabargs.add ("Oncompletetarget", gameobject);
- //play in call, parameters and similar above
- Stabargs.add ("OnUpdate", "animationupdate");
- Stabargs.add ("Onupdateparams", true);
- Stabargs.add ("Onupdatetarget", gameobject);
- Itween.stab (Gameobject, Stabargs);
- }
- //The animation is called at the start
- void Animationstart (float f)
- {
- Debug.Log ("Start:" + f);
- }
- //At the end of the animation call
- void Animationend (string f)
- {
- Debug.Log ("End:" + f);
- }
- //Call in animation
- void Animationupdate (bool f)
- {
- Debug.Log ("UPDATE:" + f);
- }
Itween Basic Audio (volume and pitch changes)