iTween.cs
iTween.cs
UI;
/*
TERMS OF USE - EASING EQUATIONS
Open source under the BSD License.
Copyright (c)2001 Robert Penner
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of
conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list
of conditions and the following disclaimer in the documentation and/or other
materials provided with the distribution.
Neither the name of the author nor the names of contributors may be used to endorse
or promote products derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#region Namespaces
using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using UnityEngine;
#endregion
/// <summary>
/// <para>Version: 2.0.5</para>
/// <para>Author: Bob Berkebile (http://pixelplacement.com)</para>
/// <para>Support: http://itween.pixelplacement.com</para>
/// </summary>
public class iTween : MonoBehaviour {
#region Variables
//private members:
private float runningTime, percentage;
private float delayStarted; //probably not neccesary that this be protected
but it shuts Unity's compiler up about this being "never used"
private bool kinematic, isLocal, loop, reverse, wasPaused, physics;
private Hashtable tweenArguments;
private Space space;
private delegate float EasingFunction( float start, float end, float Value );
private delegate void ApplyTween();
private EasingFunction ease;
private ApplyTween apply;
private AudioSource audioSource;
private Vector3[] vector3s;
private Vector2[] vector2s;
private Color[, ] colors;
private float[] floats;
private Rect[] rects;
private CRSpline path;
private Vector3 preUpdate;
private Vector3 postUpdate;
private NamedValueColor namedcolorvalue;
/// <summary>
/// The type of easing to use based on Robert Penner's open source easing
equations (http://www.robertpenner.com/easing_terms_of_use.html).
/// </summary>
public enum EaseType {
easeInQuad,
easeOutQuad,
easeInOutQuad,
easeInCubic,
easeOutCubic,
easeInOutCubic,
easeInQuart,
easeOutQuart,
easeInOutQuart,
easeInQuint,
easeOutQuint,
easeInOutQuint,
easeInSine,
easeOutSine,
easeInOutSine,
easeInExpo,
easeOutExpo,
easeInOutExpo,
easeInCirc,
easeOutCirc,
easeInOutCirc,
linear,
spring,
/* GFX47 MOD START */
//bounce,
easeInBounce,
easeOutBounce,
easeInOutBounce,
/* GFX47 MOD END */
easeInBack,
easeOutBack,
easeInOutBack,
/* GFX47 MOD START */
//elastic,
easeInElastic,
easeOutElastic,
easeInOutElastic,
/* GFX47 MOD END */
punch
}
/// <summary>
/// The type of loop (if any) to use.
/// </summary>
public enum LoopType {
/// <summary>
/// Do not loop.
/// </summary>
none,
/// <summary>
/// Rewind and replay.
/// </summary>
loop,
/// <summary>
/// Ping pong the animation back and forth.
/// </summary>
pingPong
}
/// <summary>
/// Many shaders use more than one color. Use can have iTween's Color methods
operate on them by name.
/// </summary>
public enum NamedValueColor {
/// <summary>
/// The main color of a material. Used by default and not required for
Color methods to work in iTween.
/// </summary>
_Color,
/// <summary>
/// The specular color of a material (used in specular/glossy/vertexlit
shaders).
/// </summary>
_SpecColor,
/// <summary>
/// The emissive color of a material (used in vertexlit shaders).
/// </summary>
_Emission,
/// <summary>
/// The reflection color of the material (used in reflective shaders).
/// </summary>
_ReflectColor
}
#endregion
#region Defaults
/// <summary>
/// A collection of baseline presets that iTween needs and utilizes if
certain parameters are not provided.
/// </summary>
public static class Defaults {
//general defaults:
public static float time = 1f;
public static float delay = 0f;
public static NamedValueColor namedColorValue = NamedValueColor._Color;
public static LoopType loopType = LoopType.none;
public static EaseType easeType = iTween.EaseType.easeOutExpo;
public static float lookSpeed = 3f;
public static bool isLocal = false;
public static Space space = Space.Self;
public static bool orientToPath = false;
public static Color color = Color.white;
//update defaults:
public static float updateTimePercentage = .05f;
public static float updateTime = 1f * updateTimePercentage;
//cameraFade defaults:
public static int cameraFadeDepth = 999999;
//path look ahead amount:
public static float lookAhead = .05f;
public static bool useRealTime = false; // Added by PressPlay
//look
direction:
public static Vector3 up = Vector3.up;
}
#endregion
#region #1 Static Registers
/// <summary>
/// Sets up a GameObject to avoid hiccups when an initial iTween is added.
It's advisable to run this on every object you intend to run iTween on in its Start
or Awake.
/// </summary>
/// <param name="target">
/// A <see cref="GameObject"/> to be the target to be initialized for iTween.
/// </param>
public static void Init( GameObject target ) {
MoveBy( target, Vector3.zero, 0 );
}
/// <summary>
/// Instantly changes the amount(transparency) of a camera fade and then
returns it back over time with MINIMUM customization options.
/// </summary>
/// <param name="amount">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for how
transparent the Texture2D that the camera fade uses is.
/// </param>
/// <param name="time">
/// A <see cref="System.Single"/> for the time in seconds the animation will
take to complete.
/// </param>
public static void CameraFadeFrom( float amount, float time ) {
if ( cameraFade ) {
CameraFadeFrom( Hash( "amount", amount, "time", time ) );
} else {
Debug.LogError( "iTween Error: You must first add a camera fade
object with CameraFadeAdd() before atttempting to use camera fading." );
}
}
/// <summary>
/// Instantly changes the amount(transparency) of a camera fade and then
returns it back over time with FULL customization options.
/// </summary>
/// <param name="amount">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for how
transparent the Texture2D that the camera fade uses is.
/// </param>
/// <param name="time">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time
in seconds the animation will take to complete.
/// </param>
/// <param name="delay">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time
in seconds the animation will wait before beginning.
/// </param>
/// <param name="easetype">
/// A <see cref="EaseType"/> or <see cref="System.String"/> for the shape of
the easing curve applied to the animation.
/// </param>
/// <param name="looptype">
/// A <see cref="LoopType"/> or <see cref="System.String"/> for the type of
loop to apply once the animation has completed.
/// </param>
/// <param name="onstart">
/// A <see cref="System.String"/> for the name of a function to launch at the
beginning of the animation.
/// </param>
/// <param name="onstarttarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "onstart" method.
/// </param>
/// <param name="onstartparams">
/// A <see cref="System.Object"/> for arguments to be sent to the "onstart"
method.
/// </param>
/// <param name="onupdate">
/// A <see cref="System.String"/> for the name of a function to launch on
every step of the animation.
/// </param>
/// <param name="onupdatetarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "onupdate" method.
/// </param>
/// <param name="onupdateparams">
/// A <see cref="System.Object"/> for arguments to be sent to the "onupdate"
method.
/// </param>
/// <param name="oncomplete">
/// A <see cref="System.String"/> for the name of a function to launch at the
end of the animation.
/// </param>
/// <param name="oncompletetarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "oncomplete" method.
/// </param>
/// <param name="oncompleteparams">
/// A <see cref="System.Object"/> for arguments to be sent to the
"oncomplete" method.
/// </param>
public static void CameraFadeFrom( Hashtable args ) {
//establish iTween:
if ( cameraFade ) {
ColorFrom( cameraFade, args );
} else {
Debug.LogError( "iTween Error: You must first add a camera fade
object with CameraFadeAdd() before atttempting to use camera fading." );
}
}
/// <summary>
/// Changes the amount(transparency) of a camera fade over time with MINIMUM
customization options.
/// </summary>
/// <param name="amount">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for how
transparent the Texture2D that the camera fade uses is.
/// </param>
/// <param name="time">
/// A <see cref="System.Single"/> for the time in seconds the animation will
take to complete.
/// </param>
public static void CameraFadeTo( float amount, float time ) {
if ( cameraFade ) {
CameraFadeTo( Hash( "amount", amount, "time", time ) );
} else {
Debug.LogError( "iTween Error: You must first add a camera fade
object with CameraFadeAdd() before atttempting to use camera fading." );
}
}
/// <summary>
/// Changes the amount(transparency) of a camera fade over time with FULL
customization options.
/// </summary>
/// <param name="amount">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for how
transparent the Texture2D that the camera fade uses is.
/// </param>
/// <param name="time">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time
in seconds the animation will take to complete.
/// </param>
/// <param name="delay">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time
in seconds the animation will wait before beginning.
/// </param>
/// <param name="easetype">
/// A <see cref="EaseType"/> or <see cref="System.String"/> for the shape of
the easing curve applied to the animation.
/// </param>
/// <param name="looptype">
/// A <see cref="LoopType"/> or <see cref="System.String"/> for the type of
loop to apply once the animation has completed.
/// </param>
/// <param name="onstart">
/// A <see cref="System.String"/> for the name of a function to launch at the
beginning of the animation.
/// </param>
/// <param name="onstarttarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "onstart" method.
/// </param>
/// <param name="onstartparams">
/// A <see cref="System.Object"/> for arguments to be sent to the "onstart"
method.
/// </param>
/// <param name="onupdate">
/// A <see cref="System.String"/> for the name of a function to launch on
every step of the animation.
/// </param>
/// <param name="onupdatetarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "onupdate" method.
/// </param>
/// <param name="onupdateparams">
/// A <see cref="System.Object"/> for arguments to be sent to the "onupdate"
method.
/// </param>
/// <param name="oncomplete">
/// A <see cref="System.String"/> for the name of a function to launch at the
end of the animation.
/// </param>
/// <param name="oncompletetarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "oncomplete" method.
/// </param>
/// <param name="oncompleteparams">
/// A <see cref="System.Object"/> for arguments to be sent to the
"oncomplete" method.
/// </param>
public static void CameraFadeTo( Hashtable args ) {
/*
CameraFadeAdd(Defaults.cameraFadeDepth);
if ( cameraFade ) {
//establish iTween:
ColorTo( cameraFade, args );
} else {
Debug.LogError( "iTween Error: You must first add a camera fade
object with CameraFadeAdd() before atttempting to use camera fading." );
}
}
/// <summary>
/// Returns a value to an 'oncallback' method interpolated between the
supplied 'from' and 'to' values for application as desired. Requires an 'onupdate'
callback that accepts the same type as the supplied 'from' and 'to' properties.
/// </summary>
/// <param name="from">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> or <see
cref="Vector3"/> or <see cref="Vector2"/> or <see cref="Color"/> or <see
cref="Rect"/> for the starting value.
/// </param>
/// <param name="to">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> or <see
cref="Vector3"/> or <see cref="Vector2"/> or <see cref="Color"/> or <see
cref="Rect"/> for the ending value.
/// </param>
/// <param name="time">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time
in seconds the animation will take to complete.
/// </param>
/// <param name="speed">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> can be used
instead of time to allow animation based on speed (only works with Vector2,
Vector3, and Floats)
/// </param>
/// <param name="delay">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time
in seconds the animation will wait before beginning.
/// </param>
/// <param name="easetype">
/// A <see cref="EaseType"/> or <see cref="System.String"/> for the shape of
the easing curve applied to the animation.
/// </param>
/// <param name="looptype">
/// A <see cref="LoopType"/> or <see cref="System.String"/> for the type of
loop to apply once the animation has completed.
/// </param>
/// <param name="onstart">
/// A <see cref="System.String"/> for the name of a function to launch at the
beginning of the animation.
/// </param>
/// <param name="onstarttarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "onstart" method.
/// </param>
/// <param name="onstartparams">
/// A <see cref="System.Object"/> for arguments to be sent to the "onstart"
method.
/// </param>
/// <param name="onupdate">
/// A <see cref="System.String"/> for the name of a function to launch on
every step of the animation.
/// </param>
/// <param name="onupdatetarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "onupdate" method.
/// </param>
/// <param name="onupdateparams">
/// A <see cref="System.Object"/> for arguments to be sent to the "onupdate"
method.
/// </param>
/// <param name="oncomplete">
/// A <see cref="System.String"/> for the name of a function to launch at the
end of the animation.
/// </param>
/// <param name="oncompletetarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "oncomplete" method.
/// </param>
/// <param name="oncompleteparams">
/// A <see cref="System.Object"/> for arguments to be sent to the
"oncomplete" method.
/// </param>
public static void ValueTo( GameObject target, Hashtable args ) {
//clean args:
args = iTween.CleanArgs( args );
/// <summary>
/// Changes a GameObject's alpha value instantly then returns it to the
provided alpha over time with MINIMUM customization options. If a Text or Image
component is attached, it will become the target of the animation. Identical to
using ColorFrom and using the "a" parameter.
/// </summary>
/// <param name="target">
/// A <see cref="GameObject"/> to be the target of the animation.
/// </param>
/// <param name="alpha">
/// A <see cref="System.Single"/> for the final alpha value of the animation.
/// </param>
/// <param name="time">
/// A <see cref="System.Single"/> for the time in seconds the animation will
take to complete.
/// </param>
public static void FadeFrom( GameObject target, float alpha, float time ) {
FadeFrom( target, Hash( "alpha", alpha, "time", time ) );
}
/// <summary>
/// Changes a GameObject's alpha value instantly then returns it to the
provided alpha over time with FULL customization options. If a Text or Image
component is attached, it will become the target of the animation. Identical to
using ColorFrom and using the "a" parameter.
/// </summary>
/// <param name="alpha">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
initial alpha value of the animation.
/// </param>
/// <param name="amount">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
initial alpha value of the animation.
/// </param>
/// <param name="includechildren">
/// A <see cref="System.Boolean"/> for whether or not to include children of
this GameObject. True by default.
/// </param>
/// <param name="time">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time
in seconds the animation will take to complete.
/// </param>
/// <param name="delay">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time
in seconds the animation will wait before beginning.
/// </param>
/// <param name="easetype">
/// A <see cref="EaseType"/> or <see cref="System.String"/> for the shape of
the easing curve applied to the animation.
/// </param>
/// <param name="looptype">
/// A <see cref="LoopType"/> or <see cref="System.String"/> for the type of
loop to apply once the animation has completed.
/// </param>
/// <param name="onstart">
/// A <see cref="System.String"/> for the name of a function to launch at the
beginning of the animation.
/// </param>
/// <param name="onstarttarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "onstart" method.
/// </param>
/// <param name="onstartparams">
/// A <see cref="System.Object"/> for arguments to be sent to the "onstart"
method.
/// </param>
/// <param name="onupdate">
/// A <see cref="System.String"/> for the name of a function to launch on
every step of the animation.
/// </param>
/// <param name="onupdatetarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "onupdate" method.
/// </param>
/// <param name="onupdateparams">
/// A <see cref="System.Object"/> for arguments to be sent to the "onupdate"
method.
/// </param>
/// <param name="oncomplete">
/// A <see cref="System.String"/> for the name of a function to launch at the
end of the animation.
/// </param>
/// <param name="oncompletetarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "oncomplete" method.
/// </param>
/// <param name="oncompleteparams">
/// A <see cref="System.Object"/> for arguments to be sent to the
"oncomplete" method.
/// </param>
public static void FadeFrom( GameObject target, Hashtable args ) {
ColorFrom( target, args );
}
/// <summary>
/// Changes a GameObject's alpha value over time with MINIMUM customization
options. If a Text or Image component is attached, it will become the target of
the animation. Identical to using ColorTo and using the "a" parameter.
/// </summary>
/// <param name="target">
/// A <see cref="GameObject"/> to be the target of the animation.
/// </param>
/// <param name="alpha">
/// A <see cref="System.Single"/> for the final alpha value of the animation.
/// </param>
/// <param name="time">
/// A <see cref="System.Single"/> for the time in seconds the animation will
take to complete.
/// </param>
public static void FadeTo( GameObject target, float alpha, float time ) {
FadeTo( target, Hash( "alpha", alpha, "time", time ) );
}
/// <summary>
/// Changes a GameObject's alpha value over time with FULL customization
options. If a Text or Image component is attached, it will become the target of
the animation. Identical to using ColorTo and using the "a" parameter.
/// </summary>
/// <param name="alpha">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
final alpha value of the animation.
/// </param>
/// <param name="amount">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
final alpha value of the animation.
/// </param>
/// <param name="includechildren">
/// A <see cref="System.Boolean"/> for whether or not to include children of
this GameObject. True by default.
/// </param>
/// <param name="time">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time
in seconds the animation will take to complete.
/// </param>
/// <param name="delay">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time
in seconds the animation will wait before beginning.
/// </param>
/// <param name="easetype">
/// A <see cref="EaseType"/> or <see cref="System.String"/> for the shape of
the easing curve applied to the animation.
/// </param>
/// <param name="looptype">
/// A <see cref="LoopType"/> or <see cref="System.String"/> for the type of
loop to apply once the animation has completed.
/// </param>
/// <param name="onstart">
/// A <see cref="System.String"/> for the name of a function to launch at the
beginning of the animation.
/// </param>
/// <param name="onstarttarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "onstart" method.
/// </param>
/// <param name="onstartparams">
/// A <see cref="System.Object"/> for arguments to be sent to the "onstart"
method.
/// </param>
/// <param name="onupdate">
/// A <see cref="System.String"/> for the name of a function to launch on
every step of the animation.
/// </param>
/// <param name="onupdatetarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "onupdate" method.
/// </param>
/// <param name="onupdateparams">
/// A <see cref="System.Object"/> for arguments to be sent to the "onupdate"
method.
/// </param>
/// <param name="oncomplete">
/// A <see cref="System.String"/> for the name of a function to launch at the
end of the animation.
/// </param>
/// <param name="oncompletetarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "oncomplete" method.
/// </param>
/// <param name="oncompleteparams">
/// A <see cref="System.Object"/> for arguments to be sent to the
"oncomplete" method.
/// </param>
public static void FadeTo( GameObject target, Hashtable args ) {
ColorTo( target, args );
}
/// <summary>
/// Changes a GameObject's color values instantly then returns them to the
provided properties over time with MINIMUM customization options. If a Text or
Image component is attached, it will become the target of the animation.
/// </summary>
/// <param name="target">
/// A <see cref="GameObject"/> to be the target of the animation.
/// </param>
/// <param name="color">
/// A <see cref="Color"/> to change the GameObject's color to.
/// </param>
/// <param name="time">
/// A <see cref="System.Single"/> for the time in seconds the animation will
take to complete.
/// </param>
public static void ColorFrom( GameObject target, Color color, float time ) {
ColorFrom( target, Hash( "color", color, "time", time ) );
}
/// <summary>
/// Changes a GameObject's color values instantly then returns them to the
provided properties over time with FULL customization options. If a Text or Image
component is attached, it will become the target of the animation.
/// </summary>
/// <param name="color">
/// A <see cref="Color"/> to change the GameObject's color to.
/// </param>
/// <param name="r">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
individual setting of the color red.
/// </param>
/// <param name="g">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
individual setting of the color green.
/// </param>
/// <param name="b">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
individual setting of the color green.
/// </param>
/// <param name="a">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
individual setting of the alpha.
/// </param>
/// <param name="namedcolorvalue">
/// A <see cref="NamedColorValue"/> or <see cref="System.String"/> for the
individual setting of the alpha.
/// </param>
/// <param name="includechildren">
/// A <see cref="System.Boolean"/> for whether or not to include children of
this GameObject. True by default.
/// </param>
/// <param name="time">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time
in seconds the animation will take to complete.
/// </param>
/// <param name="delay">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time
in seconds the animation will wait before beginning.
/// </param>
/// <param name="easetype">
/// A <see cref="EaseType"/> or <see cref="System.String"/> for the shape of
the easing curve applied to the animation.
/// </param>
/// <param name="looptype">
/// A <see cref="LoopType"/> or <see cref="System.String"/> for the type of
loop to apply once the animation has completed.
/// </param>
/// <param name="onstart">
/// A <see cref="System.String"/> for the name of a function to launch at the
beginning of the animation.
/// </param>
/// <param name="onstarttarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "onstart" method.
/// </param>
/// <param name="onstartparams">
/// A <see cref="System.Object"/> for arguments to be sent to the "onstart"
method.
/// </param>
/// <param name="onupdate">
/// A <see cref="System.String"/> for the name of a function to launch on
every step of the animation.
/// </param>
/// <param name="onupdatetarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "onupdate" method.
/// </param>
/// <param name="onupdateparams">
/// A <see cref="System.Object"/> for arguments to be sent to the "onupdate"
method.
/// </param>
/// <param name="oncomplete">
/// A <see cref="System.String"/> for the name of a function to launch at the
end of the animation.
/// </param>
/// <param name="oncompletetarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "oncomplete" method.
/// </param>
/// <param name="oncompleteparams">
/// A <see cref="System.Object"/> for arguments to be sent to the
"oncomplete" method.
/// </param>
public static void ColorFrom( GameObject target, Hashtable args ) {
Color fromColor = new Color();
Color tempColor = new Color();
//clean args:
args = iTween.CleanArgs( args );
//handle children:
if ( !args.Contains( "includechildren" ) ||
(bool)args[ "includechildren" ] ) {
foreach ( Transform child in target.transform ) {
Hashtable argsCopy = (Hashtable)args.Clone();
argsCopy[ "ischild" ] = true;
ColorFrom( child.gameObject, argsCopy );
}
}
//alpha or amount?
if ( args.Contains( "amount" ) ) {
fromColor.a = (float)args[ "amount" ];
args.Remove( "amount" );
} else if ( args.Contains( "alpha" ) ) {
fromColor.a = (float)args[ "alpha" ];
args.Remove( "alpha" );
}
//apply fromColor:
if ( target.GetComponent<Image>() ) {
target.GetComponent<Image>().color = fromColor;
} else if ( target.GetComponent<Text>() ) {
target.GetComponent<Text>().material.color = fromColor;
} else if ( target.GetComponent<Renderer>() ) {
target.GetComponent<Renderer>().material.color = fromColor;
} else if ( target.GetComponent<Light>() ) {
target.GetComponent<Light>().color = fromColor;
}
//establish iTween:
args[ "type" ] = "color";
args[ "method" ] = "to";
Launch( target, args );
}
/// <summary>
/// Changes a GameObject's color values over time with MINIMUM customization
options. If a Text or Image component is attached, they will become the target of
the animation.
/// </summary>
/// <param name="target">
/// A <see cref="GameObject"/> to be the target of the animation.
/// </param>
/// <param name="color">
/// A <see cref="Color"/> to change the GameObject's color to.
/// </param>
/// <param name="time">
/// A <see cref="System.Single"/> for the time in seconds the animation will
take to complete.
/// </param>
public static void ColorTo( GameObject target, Color color, float time ) {
ColorTo( target, Hash( "color", color, "time", time ) );
}
/// <summary>
/// Changes a GameObject's color values over time with FULL customization
options. If a Text or Image component is attached, they will become the target of
the animation.
/// </summary>
/// <param name="color">
/// A <see cref="Color"/> to change the GameObject's color to.
/// </param>
/// <param name="r">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
individual setting of the color red.
/// </param>
/// <param name="g">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
individual setting of the color green.
/// </param>
/// <param name="b">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
individual setting of the color green.
/// </param>
/// <param name="a">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
individual setting of the alpha.
/// </param>
/// <param name="namedcolorvalue">
/// A <see cref="NamedColorValue"/> or <see cref="System.String"/> for the
individual setting of the alpha.
/// </param>
/// <param name="includechildren">
/// A <see cref="System.Boolean"/> for whether or not to include children of
this GameObject. True by default.
/// </param>
/// <param name="time">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time
in seconds the animation will take to complete.
/// </param>
/// <param name="delay">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time
in seconds the animation will wait before beginning.
/// </param>
/// <param name="easetype">
/// A <see cref="EaseType"/> or <see cref="System.String"/> for the shape of
the easing curve applied to the animation.
/// </param>
/// <param name="looptype">
/// A <see cref="LoopType"/> or <see cref="System.String"/> for the type of
loop to apply once the animation has completed.
/// </param>
/// <param name="onstart">
/// A <see cref="System.String"/> for the name of a function to launch at the
beginning of the animation.
/// </param>
/// <param name="onstarttarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "onstart" method.
/// </param>
/// <param name="onstartparams">
/// A <see cref="System.Object"/> for arguments to be sent to the "onstart"
method.
/// </param>
/// <param name="onupdate">
/// A <see cref="System.String"/> for the name of a function to launch on
every step of the animation.
/// </param>
/// <param name="onupdatetarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "onupdate" method.
/// </param>
/// <param name="onupdateparams">
/// A <see cref="System.Object"/> for arguments to be sent to the "onupdate"
method.
/// </param>
/// <param name="oncomplete">
/// A <see cref="System.String"/> for the name of a function to launch at the
end of the animation.
/// </param>
/// <param name="oncompletetarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "oncomplete" method.
/// </param>
/// <param name="oncompleteparams">
/// A <see cref="System.Object"/> for arguments to be sent to the
"oncomplete" method.
/// </param>
public static void ColorTo( GameObject target, Hashtable args ) {
//clean args:
args = iTween.CleanArgs( args );
//handle children:
if ( !args.Contains( "includechildren" ) ||
(bool)args[ "includechildren" ] ) {
foreach ( Transform child in target.transform ) {
Hashtable argsCopy = (Hashtable)args.Clone();
argsCopy[ "ischild" ] = true;
ColorTo( child.gameObject, argsCopy );
}
}
//establish iTween:
args[ "type" ] = "color";
args[ "method" ] = "to";
Launch( target, args );
}
/// <summary>
/// Instantly changes an AudioSource's volume and pitch then returns it to
it's starting volume and pitch over time with MINIMUM customization options.
Default AudioSource attached to GameObject will be used (if one exists) if not
supplied.
/// </summary>
/// <param name="target">
/// A <see cref="GameObject"/> to be the target of the animation which holds
the AudioSource to be changed.
/// </param>
/// <param name="volume"> for the target level of volume.
/// A <see cref="System.Single"/>
/// </param>
/// <param name="pitch"> for the target pitch.
/// A <see cref="System.Single"/>
/// </param>
/// <param name="time">
/// A <see cref="System.Single"/> for the time in seconds the animation will
take to complete.
/// </param>
public static void AudioFrom( GameObject target, float volume, float pitch,
float time ) {
AudioFrom( target, Hash( "volume", volume, "pitch", pitch, "time", time
) );
}
/// <summary>
/// Instantly changes an AudioSource's volume and pitch then returns it to
it's starting volume and pitch over time with FULL customization options. Default
AudioSource attached to GameObject will be used (if one exists) if not supplied.
/// </summary>
/// <param name="audiosource">
/// A <see cref="AudioSource"/> for which AudioSource to use.
/// </param>
/// <param name="volume">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
target level of volume.
/// </param>
/// <param name="pitch">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
target pitch.
/// </param>
/// <param name="time">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time
in seconds the animation will take to complete.
/// </param>
/// <param name="delay">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time
in seconds the animation will wait before beginning.
/// </param>
/// <param name="easetype">
/// A <see cref="EaseType"/> or <see cref="System.String"/> for the shape of
the easing curve applied to the animation.
/// </param>
/// <param name="looptype">
/// A <see cref="LoopType"/> or <see cref="System.String"/> for the type of
loop to apply once the animation has completed.
/// </param>
/// <param name="onstart">
/// A <see cref="System.String"/> for the name of a function to launch at the
beginning of the animation.
/// </param>
/// <param name="onstarttarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "onstart" method.
/// </param>
/// <param name="onstartparams">
/// A <see cref="System.Object"/> for arguments to be sent to the "onstart"
method.
/// </param>
/// <param name="onupdate">
/// A <see cref="System.String"/> for the name of a function to launch on
every step of the animation.
/// </param>
/// <param name="onupdatetarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "onupdate" method.
/// </param>
/// <param name="onupdateparams">
/// A <see cref="System.Object"/> for arguments to be sent to the "onupdate"
method.
/// </param>
/// <param name="oncomplete">
/// A <see cref="System.String"/> for the name of a function to launch at the
end of the animation.
/// </param>
/// <param name="oncompletetarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "oncomplete" method.
/// </param>
/// <param name="oncompleteparams">
/// A <see cref="System.Object"/> for arguments to be sent to the
"oncomplete" method.
/// </param>
public static void AudioFrom( GameObject target, Hashtable args ) {
Vector2 tempAudioProperties;
Vector2 fromAudioProperties;
AudioSource tempAudioSource;
//clean args:
args = iTween.CleanArgs( args );
//set tempAudioSource:
if ( args.Contains( "audiosource" ) ) {
tempAudioSource = (AudioSource)args[ "audiosource" ];
} else {
if ( target.GetComponent<AudioSource>() ) {
tempAudioSource = target.GetComponent<AudioSource>();
} else {
//throw error if no AudioSource is available:
Debug.LogError( "iTween Error: AudioFrom requires an
AudioSource." );
return;
}
}
//set tempAudioProperties:
tempAudioProperties.x = fromAudioProperties.x = tempAudioSource.volume;
tempAudioProperties.y = fromAudioProperties.y = tempAudioSource.pitch;
//apply fromAudioProperties:
tempAudioSource.volume = fromAudioProperties.x;
tempAudioSource.pitch = fromAudioProperties.y;
//establish iTween:
args[ "type" ] = "audio";
args[ "method" ] = "to";
Launch( target, args );
}
/// <summary>
/// Fades volume and pitch of an AudioSource with MINIMUM customization
options. Default AudioSource attached to GameObject will be used (if one exists)
if not supplied.
/// </summary>
/// <param name="target">
/// A <see cref="GameObject"/> to be the target of the animation which holds
the AudioSource to be changed.
/// </param>
/// <param name="volume"> for the target level of volume.
/// A <see cref="System.Single"/>
/// </param>
/// <param name="pitch"> for the target pitch.
/// A <see cref="System.Single"/>
/// </param>
/// <param name="time">
/// A <see cref="System.Single"/> for the time in seconds the animation will
take to complete.
/// </param>
public static void AudioTo( GameObject target, float volume, float pitch,
float time ) {
AudioTo( target, Hash( "volume", volume, "pitch", pitch, "time", time )
);
}
/// <summary>
/// Fades volume and pitch of an AudioSource with FULL customization options.
Default AudioSource attached to GameObject will be used (if one exists) if not
supplied.
/// </summary>
/// <param name="audiosource">
/// A <see cref="AudioSource"/> for which AudioSource to use.
/// </param>
/// <param name="volume">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
target level of volume.
/// </param>
/// <param name="pitch">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
target pitch.
/// </param>
/// <param name="time">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time
in seconds the animation will take to complete.
/// </param>
/// <param name="delay">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time
in seconds the animation will wait before beginning.
/// </param>
/// <param name="easetype">
/// A <see cref="EaseType"/> or <see cref="System.String"/> for the shape of
the easing curve applied to the animation.
/// </param>
/// <param name="looptype">
/// A <see cref="LoopType"/> or <see cref="System.String"/> for the type of
loop to apply once the animation has completed.
/// </param>
/// <param name="onstart">
/// A <see cref="System.String"/> for the name of a function to launch at the
beginning of the animation.
/// </param>
/// <param name="onstarttarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "onstart" method.
/// </param>
/// <param name="onstartparams">
/// A <see cref="System.Object"/> for arguments to be sent to the "onstart"
method.
/// </param>
/// <param name="onupdate">
/// A <see cref="System.String"/> for the name of a function to launch on
every step of the animation.
/// </param>
/// <param name="onupdatetarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "onupdate" method.
/// </param>
/// <param name="onupdateparams">
/// A <see cref="System.Object"/> for arguments to be sent to the "onupdate"
method.
/// </param>
/// <param name="oncomplete">
/// A <see cref="System.String"/> for the name of a function to launch at the
end of the animation.
/// </param>
/// <param name="oncompletetarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "oncomplete" method.
/// </param>
/// <param name="oncompleteparams">
/// A <see cref="System.Object"/> for arguments to be sent to the
"oncomplete" method.
/// </param>
public static void AudioTo( GameObject target, Hashtable args ) {
//clean args:
args = iTween.CleanArgs( args );
//establish iTween:
args[ "type" ] = "audio";
args[ "method" ] = "to";
Launch( target, args );
}
/// <summary>
/// Plays an AudioClip once based on supplied volume and pitch and following
any delay with MINIMUM customization options. AudioSource is optional as iTween
will provide one.
/// </summary>
/// <param name="target">
/// A <see cref="GameObject"/> to be the target of the animation which holds
the AudioSource to be utilized.
/// </param>
/// <param name="audioclip">
/// A <see cref="AudioClip"/> for a reference to the AudioClip to be played.
/// </param>
/// <param name="delay">
/// A <see cref="System.Single"/> for the time in seconds the action will
wait before beginning.
/// </param>
public static void Stab( GameObject target, AudioClip audioclip, float
delay ) {
Stab( target, Hash( "audioclip", audioclip, "delay", delay ) );
}
/// <summary>
/// Plays an AudioClip once based on supplied volume and pitch and following
any delay with FULL customization options. AudioSource is optional as iTween will
provide one.
/// </summary>
/// <param name="audioclip">
/// A <see cref="AudioClip"/> for a reference to the AudioClip to be played.
/// </param>
/// <param name="audiosource">
/// A <see cref="AudioSource"/> for which AudioSource to use
/// </param>
/// <param name="volume">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
target level of volume.
/// </param>
/// <param name="pitch">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
target pitch.
/// </param>
/// <param name="delay">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time
in seconds the action will wait before beginning.
/// </param>
/// <param name="onstart">
/// A <see cref="System.String"/> for the name of a function to launch at the
beginning of the animation.
/// </param>
/// <param name="onstarttarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "onstart" method.
/// </param>
/// <param name="onstartparams">
/// A <see cref="System.Object"/> for arguments to be sent to the "onstart"
method.
/// </param>
/// <param name="onupdate">
/// A <see cref="System.String"/> for the name of a function to launch on
every step of the animation.
/// </param>
/// <param name="onupdatetarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "onupdate" method.
/// </param>
/// <param name="onupdateparams">
/// A <see cref="System.Object"/> for arguments to be sent to the "onupdate"
method.
/// </param>
/// <param name="oncomplete">
/// A <see cref="System.String"/> for the name of a function to launch at the
end of the animation.
/// </param>
/// <param name="oncompletetarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "oncomplete" method.
/// </param>
/// <param name="oncompleteparams">
/// A <see cref="System.Object"/> for arguments to be sent to the
"oncomplete" method.
/// </param>
public static void Stab( GameObject target, Hashtable args ) {
//clean args:
args = iTween.CleanArgs( args );
//establish iTween:
args[ "type" ] = "stab";
Launch( target, args );
}
/// <summary>
/// Instantly rotates a GameObject to look at the supplied Vector3 then
returns it to it's starting rotation over time with MINIMUM customization options.
/// </summary>
/// <param name="target">
/// A <see cref="GameObject"/> to be the target of the animation.
/// </param>
/// <param name="looktarget">
/// A <see cref="Vector3"/> to be the Vector3 that the target will look
towards.
/// </param>
/// <param name="time">
/// A <see cref="System.Single"/> for the time in seconds the animation will
take to complete.
/// </param>
public static void LookFrom( GameObject target, Vector3 looktarget, float
time ) {
LookFrom( target, Hash( "looktarget", looktarget, "time", time ) );
}
/// <summary>
/// Instantly rotates a GameObject to look at a supplied Transform or Vector3
then returns it to it's starting rotation over time with FULL customization
options.
/// </summary>
/// <param name="looktarget">
/// A <see cref="Transform"/> or <see cref="Vector3"/> for a target the
GameObject will look at.
/// </param>
/// <param name="axis">
/// A <see cref="System.String"/>. Restricts rotation to the supplied axis
only.
/// </param>
/// <param name="time">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time
in seconds the animation will take to complete.
/// </param>
/// <param name="speed">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> can be used
instead of time to allow animation based on speed
/// </param>
/// <param name="delay">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time
in seconds the animation will wait before beginning.
/// </param>
/// <param name="easetype">
/// A <see cref="EaseType"/> or <see cref="System.String"/> for the shape of
the easing curve applied to the animation.
/// </param>
/// <param name="looptype">
/// A <see cref="LoopType"/> or <see cref="System.String"/> for the type of
loop to apply once the animation has completed.
/// </param>
/// <param name="onstart">
/// A <see cref="System.String"/> for the name of a function to launch at the
beginning of the animation.
/// </param>
/// <param name="onstarttarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "onstart" method.
/// </param>
/// <param name="onstartparams">
/// A <see cref="System.Object"/> for arguments to be sent to the "onstart"
method.
/// </param>
/// <param name="onupdate">
/// A <see cref="System.String"/> for the name of a function to launch on
every step of the animation.
/// </param>
/// <param name="onupdatetarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "onupdate" method.
/// </param>
/// <param name="onupdateparams">
/// A <see cref="System.Object"/> for arguments to be sent to the "onupdate"
method.
/// </param>
/// <param name="oncomplete">
/// A <see cref="System.String"/> for the name of a function to launch at the
end of the animation.
/// </param>
/// <param name="oncompletetarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "oncomplete" method.
/// </param>
/// <param name="oncompleteparams">
/// A <see cref="System.Object"/> for arguments to be sent to the
"oncomplete" method.
/// </param>
public static void LookFrom( GameObject target, Hashtable args ) {
Vector3 tempRotation;
Vector3 tempRestriction;
//clean args:
args = iTween.CleanArgs( args );
//set look:
tempRotation = target.transform.eulerAngles;
if ( args[ "looktarget" ].GetType() == typeof( Transform ) ) {
//target.transform.LookAt((Transform)args["looktarget"]);
target.transform.LookAt( (Transform)args[ "looktarget" ],
(Vector3?)args[ "up" ] ?? Defaults.up );
} else if ( args[ "looktarget" ].GetType() == typeof( Vector3 ) ) {
//target.transform.LookAt((Vector3)args["looktarget"]);
target.transform.LookAt( (Vector3)args[ "looktarget" ],
(Vector3?)args[ "up" ] ?? Defaults.up );
}
//axis restriction:
if ( args.Contains( "axis" ) ) {
tempRestriction = target.transform.eulerAngles;
switch ( (string)args[ "axis" ] ) {
case "x":
tempRestriction.y = tempRotation.y;
tempRestriction.z = tempRotation.z;
break;
case "y":
tempRestriction.x = tempRotation.x;
tempRestriction.z = tempRotation.z;
break;
case "z":
tempRestriction.x = tempRotation.x;
tempRestriction.y = tempRotation.y;
break;
}
target.transform.eulerAngles = tempRestriction;
}
//establish iTween
args[ "type" ] = "rotate";
args[ "method" ] = "to";
Launch( target, args );
}
/// <summary>
/// Rotates a GameObject to look at the supplied Vector3 over time with
MINIMUM customization options.
/// </summary>
/// <param name="target">
/// A <see cref="GameObject"/> to be the target of the animation.
/// </param>
/// <param name="looktarget">
/// A <see cref="Vector3"/> to be the Vector3 that the target will look
towards.
/// </param>
/// <param name="time">
/// A <see cref="System.Single"/> for the time in seconds the animation will
take to complete.
/// </param>
public static void LookTo( GameObject target, Vector3 looktarget, float
time ) {
LookTo( target, Hash( "looktarget", looktarget, "time", time ) );
}
/// <summary>
/// Rotates a GameObject to look at a supplied Transform or Vector3 over time
with FULL customization options.
/// </summary>
/// <param name="looktarget">
/// A <see cref="Transform"/> or <see cref="Vector3"/> for a target the
GameObject will look at.
/// </param>
/// <param name="axis">
/// A <see cref="System.String"/>. Restricts rotation to the supplied axis
only.
/// </param>
/// <param name="time">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time
in seconds the animation will take to complete.
/// </param>
/// <param name="speed">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> can be used
instead of time to allow animation based on speed
/// </param>
/// <param name="delay">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time
in seconds the animation will wait before beginning.
/// </param>
/// <param name="easetype">
/// A <see cref="EaseType"/> or <see cref="System.String"/> for the shape of
the easing curve applied to the animation.
/// </param>
/// <param name="looptype">
/// A <see cref="LoopType"/> or <see cref="System.String"/> for the type of
loop to apply once the animation has completed.
/// </param>
/// <param name="onstart">
/// A <see cref="System.String"/> for the name of a function to launch at the
beginning of the animation.
/// </param>
/// <param name="onstarttarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "onstart" method.
/// </param>
/// <param name="onstartparams">
/// A <see cref="System.Object"/> for arguments to be sent to the "onstart"
method.
/// </param>
/// <param name="onupdate">
/// A <see cref="System.String"/> for the name of a function to launch on
every step of the animation.
/// </param>
/// <param name="onupdatetarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "onupdate" method.
/// </param>
/// <param name="onupdateparams">
/// A <see cref="System.Object"/> for arguments to be sent to the "onupdate"
method.
/// </param>
/// <param name="oncomplete">
/// A <see cref="System.String"/> for the name of a function to launch at the
end of the animation.
/// </param>
/// <param name="oncompletetarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "oncomplete" method.
/// </param>
/// <param name="oncompleteparams">
/// A <see cref="System.Object"/> for arguments to be sent to the
"oncomplete" method.
/// </param>
public static void LookTo( GameObject target, Hashtable args ) {
//clean args:
args = iTween.CleanArgs( args );
//establish iTween
args[ "type" ] = "look";
args[ "method" ] = "to";
Launch( target, args );
}
/// <summary>
/// Changes a GameObject's position over time to a supplied destination with
MINIMUM customization options.
/// </summary>
/// <param name="target">
/// A <see cref="GameObject"/> to be the target of the animation.
/// </param>
/// <param name="position">
/// A <see cref="Vector3"/> for the destination Vector3.
/// </param>
/// <param name="time">
/// A <see cref="System.Single"/> for the time in seconds the animation will
take to complete.
/// </param>
public static void MoveTo( GameObject target, Vector3 position, float time )
{
MoveTo( target, Hash( "position", position, "time", time ) );
}
/// <summary>
/// Changes a GameObject's position over time to a supplied destination with
FULL customization options.
/// </summary>
/// <param name="position">
/// A <see cref="Transform"/> or <see cref="Vector3"/> for a point in space
the GameObject will animate to.
/// </param>
/// <param name="path">
/// A <see cref="Transform[]"/> or <see cref="Vector3[]"/> for a list of
points to draw a Catmull-Rom through for a curved animation path.
/// </param>
/// <param name="movetopath">
/// A <see cref="System.Boolean"/> for whether to automatically generate a
curve from the GameObject's current position to the beginning of the path. True by
default.
/// </param>
/// <param name="x">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
individual setting of the x axis.
/// </param>
/// <param name="y">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
individual setting of the y axis.
/// </param>
/// <param name="z">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
individual setting of the z axis.
/// </param>
/// <param name="orienttopath">
/// A <see cref="System.Boolean"/> for whether or not the GameObject will
orient to its direction of travel. False by default.
/// </param>
/// <param name="looktarget">
/// A <see cref="Vector3"/> or A <see cref="Transform"/> for a target the
GameObject will look at.
/// </param>
/// <param name="looktime">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time
in seconds the object will take to look at either the "looktarget" or
"orienttopath".
/// </param>
/// <param name="lookahead">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for how much
of a percentage to look ahead on a path to influence how strict "orientopath" is.
/// </param>
/// <param name="axis">
/// A <see cref="System.String"/>. Restricts rotation to the supplied axis
only.
/// </param>
/// <param name="islocal">
/// A <see cref="System.Boolean"/> for whether to animate in world space or
relative to the parent. False by default.
/// </param>
/// <param name="time">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time
in seconds the animation will take to complete.
/// </param>
/// <param name="speed">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> can be used
instead of time to allow animation based on speed
/// </param>
/// <param name="delay">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time
in seconds the animation will wait before beginning.
/// </param>
/// <param name="easetype">
/// A <see cref="EaseType"/> or <see cref="System.String"/> for the shape of
the easing curve applied to the animation.
/// </param>
/// <param name="looptype">
/// A <see cref="LoopType"/> or <see cref="System.String"/> for the type of
loop to apply once the animation has completed.
/// </param>
/// <param name="onstart">
/// A <see cref="System.String"/> for the name of a function to launch at the
beginning of the animation.
/// </param>
/// <param name="onstarttarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "onstart" method.
/// </param>
/// <param name="onstartparams">
/// A <see cref="System.Object"/> for arguments to be sent to the "onstart"
method.
/// </param>
/// <param name="onupdate">
/// A <see cref="System.String"/> for the name of a function to launch on
every step of the animation.
/// </param>
/// <param name="onupdatetarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "onupdate" method.
/// </param>
/// <param name="onupdateparams">
/// A <see cref="System.Object"/> for arguments to be sent to the "onupdate"
method.
/// </param>
/// <param name="oncomplete">
/// A <see cref="System.String"/> for the name of a function to launch at the
end of the animation.
/// </param>
/// <param name="oncompletetarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "oncomplete" method.
/// </param>
/// <param name="oncompleteparams">
/// A <see cref="System.Object"/> for arguments to be sent to the
"oncomplete" method.
/// </param>
public static void MoveTo( GameObject target, Hashtable args ) {
//clean args:
args = iTween.CleanArgs( args );
//establish iTween:
args[ "type" ] = "move";
args[ "method" ] = "to";
Launch( target, args );
}
/// <summary>
/// Instantly changes a GameObject's position to a supplied destination then
returns it to it's starting position over time with MINIMUM customization options.
/// </summary>
/// <param name="target">
/// A <see cref="GameObject"/> to be the target of the animation.
/// </param>
/// <param name="position">
/// A <see cref="Vector3"/> for the destination Vector3.
/// </param>
/// <param name="time">
/// A <see cref="System.Single"/> for the time in seconds the animation will
take to complete.
/// </param>
public static void MoveFrom( GameObject target, Vector3 position, float
time ) {
MoveFrom( target, Hash( "position", position, "time", time ) );
}
/// <summary>
/// Instantly changes a GameObject's position to a supplied destination then
returns it to it's starting position over time with FULL customization options.
/// </summary>
/// <param name="position">
/// A <see cref="Transform"/> or <see cref="Vector3"/> for a point in space
the GameObject will animate to.
/// </param>
/// <param name="path">
/// A <see cref="Transform[]"/> or <see cref="Vector3[]"/> for a list of
points to draw a Catmull-Rom through for a curved animation path.
/// </param>
/// <param name="movetopath">
/// A <see cref="System.Boolean"/> for whether to automatically generate a
curve from the GameObject's current position to the beginning of the path. True by
default.
/// </param>
/// <param name="x">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
individual setting of the x axis.
/// </param>
/// <param name="y">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
individual setting of the y axis.
/// </param>
/// <param name="z">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
individual setting of the z axis.
/// </param>
/// <param name="orienttopath">
/// A <see cref="System.Boolean"/> for whether or not the GameObject will
orient to its direction of travel. False by default.
/// </param>
/// <param name="looktarget">
/// A <see cref="Vector3"/> or A <see cref="Transform"/> for a target the
GameObject will look at.
/// </param>
/// <param name="looktime">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time
in seconds the object will take to look at either the "looktarget" or
"orienttopath".
/// </param>
/// <param name="lookahead">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for how much
of a percentage to look ahead on a path to influence how strict "orientopath" is.
/// </param>
/// <param name="islocal">
/// A <see cref="System.Boolean"/> for whether to animate in world space or
relative to the parent. False by default.
/// </param>
/// <param name="time">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time
in seconds the animation will take to complete.
/// </param>
/// <param name="speed">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> can be used
instead of time to allow animation based on speed
/// </param>
/// <param name="delay">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time
in seconds the animation will wait before beginning.
/// </param>
/// <param name="easetype">
/// A <see cref="EaseType"/> or <see cref="System.String"/> for the shape of
the easing curve applied to the animation.
/// </param>
/// <param name="looptype">
/// A <see cref="LoopType"/> or <see cref="System.String"/> for the type of
loop to apply once the animation has completed.
/// </param>
/// <param name="onstart">
/// A <see cref="System.String"/> for the name of a function to launch at the
beginning of the animation.
/// </param>
/// <param name="onstarttarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "onstart" method.
/// </param>
/// <param name="onstartparams">
/// A <see cref="System.Object"/> for arguments to be sent to the "onstart"
method.
/// </param>
/// <param name="onupdate">
/// A <see cref="System.String"/> for the name of a function to launch on
every step of the animation.
/// </param>
/// <param name="onupdatetarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "onupdate" method.
/// </param>
/// <param name="onupdateparams">
/// A <see cref="System.Object"/> for arguments to be sent to the "onupdate"
method.
/// </param>
/// <param name="oncomplete">
/// A <see cref="System.String"/> for the name of a function to launch at the
end of the animation.
/// </param>
/// <param name="oncompletetarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "oncomplete" method.
/// </param>
/// <param name="oncompleteparams">
/// A <see cref="System.Object"/> for arguments to be sent to the
"oncomplete" method.
/// </param>
public static void MoveFrom( GameObject target, Hashtable args ) {
//clean args:
args = iTween.CleanArgs( args );
bool tempIsLocal;
//set tempIsLocal:
if ( args.Contains( "islocal" ) ) {
tempIsLocal = (bool)args[ "islocal" ];
} else {
tempIsLocal = Defaults.isLocal;
}
if ( args.Contains( "path" ) ) {
Vector3[] fromPath;
Vector3[] suppliedPath;
if ( args[ "path" ].GetType() == typeof( Vector3[] ) ) {
Vector3[] temp = (Vector3[])args[ "path" ];
suppliedPath = new Vector3[ temp.Length ];
Array.Copy( temp, suppliedPath, temp.Length );
} else {
Transform[] temp = (Transform[])args[ "path" ];
suppliedPath = new Vector3[ temp.Length ];
for ( int i = 0; i < temp.Length; i++ ) {
suppliedPath[ i ] = temp[ i ].position;
}
}
if ( suppliedPath[ suppliedPath.Length - 1 ] !=
target.transform.position ) {
fromPath = new Vector3[ suppliedPath.Length + 1 ];
Array.Copy( suppliedPath, fromPath, suppliedPath.Length );
if ( tempIsLocal ) {
fromPath[ fromPath.Length - 1 ] =
target.transform.localPosition;
target.transform.localPosition = fromPath[ 0 ];
} else {
fromPath[ fromPath.Length - 1 ] =
target.transform.position;
target.transform.position = fromPath[ 0 ];
}
args[ "path" ] = fromPath;
} else {
if ( tempIsLocal ) {
target.transform.localPosition = suppliedPath[ 0 ];
} else {
target.transform.position = suppliedPath[ 0 ];
}
args[ "path" ] = suppliedPath;
}
} else {
Vector3 tempPosition;
Vector3 fromPosition;
//apply fromPosition:
if ( tempIsLocal ) {
target.transform.localPosition = fromPosition;
} else {
target.transform.position = fromPosition;
}
//establish iTween:
args[ "type" ] = "move";
args[ "method" ] = "to";
Launch( target, args );
}
/// <summary>
/// Translates a GameObject's position over time with MINIMUM customization
options.
/// </summary>
/// <param name="target">
/// A <see cref="GameObject"/> to be the target of the animation.
/// </param>
/// <param name="amount">
/// A <see cref="Vector3"/> for the amount of change in position to move the
GameObject.
/// </param>
/// <param name="time">
/// A <see cref="System.Single"/> for the time in seconds the animation will
take to complete.
/// </param>
public static void MoveAdd( GameObject target, Vector3 amount, float time ) {
MoveAdd( target, Hash( "amount", amount, "time", time ) );
}
/// <summary>
/// Translates a GameObject's position over time with FULL customization
options.
/// </summary>
/// <param name="amount">
/// A <see cref="Vector3"/> for the amount of change in position to move the
GameObject.
/// </param>
/// <param name="x">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
individual setting of the x axis.
/// </param>
/// <param name="y">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
individual setting of the y axis.
/// </param>
/// <param name="z">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
individual setting of the z axis.
/// </param>
/// <param name="orienttopath">
/// A <see cref="System.Boolean"/> for whether or not the GameObject will
orient to its direction of travel. False by default.
/// </param>
/// <param name="looktarget">
/// A <see cref="Vector3"/> or A <see cref="Transform"/> for a target the
GameObject will look at.
/// </param>
/// <param name="looktime">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time
in seconds the object will take to look at either the "looktarget" or
"orienttopath".
/// </param>
/// <param name="axis">
/// A <see cref="System.String"/>. Restricts rotation to the supplied axis
only.
/// </param>
/// <param name="space">
/// A <see cref="Space"/> or <see cref="System.String"/> for applying the
transformation in either the world coordinate or local cordinate system. Defaults
to local space.
/// </param>
/// <param name="time">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time
in seconds the animation will take to complete.
/// </param>
/// <param name="speed">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> can be used
instead of time to allow animation based on speed
/// </param>
/// <param name="delay">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time
in seconds the animation will wait before beginning.
/// </param>
/// <param name="easetype">
/// A <see cref="EaseType"/> or <see cref="System.String"/> for the shape of
the easing curve applied to the animation.
/// </param>
/// <param name="looptype">
/// A <see cref="LoopType"/> or <see cref="System.String"/> for the type of
loop to apply once the animation has completed.
/// </param>
/// <param name="onstart">
/// A <see cref="System.String"/> for the name of a function to launch at the
beginning of the animation.
/// </param>
/// <param name="onstarttarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "onstart" method.
/// </param>
/// <param name="onstartparams">
/// A <see cref="System.Object"/> for arguments to be sent to the "onstart"
method.
/// </param>
/// <param name="onupdate">
/// A <see cref="System.String"/> for the name of a function to launch on
every step of the animation.
/// </param>
/// <param name="onupdatetarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "onupdate" method.
/// </param>
/// <param name="onupdateparams">
/// A <see cref="System.Object"/> for arguments to be sent to the "onupdate"
method.
/// </param>
/// <param name="oncomplete">
/// A <see cref="System.String"/> for the name of a function to launch at the
end of the animation.
/// </param>
/// <param name="oncompletetarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "oncomplete" method.
/// </param>
/// <param name="oncompleteparams">
/// A <see cref="System.Object"/> for arguments to be sent to the
"oncomplete" method.
/// </param>
public static void MoveAdd( GameObject target, Hashtable args ) {
//clean args:
args = iTween.CleanArgs( args );
//establish iTween:
args[ "type" ] = "move";
args[ "method" ] = "add";
Launch( target, args );
}
/// <summary>
/// Adds the supplied coordinates to a GameObject's postion with MINIMUM
customization options.
/// </summary>
/// <param name="target">
/// A <see cref="GameObject"/> to be the target of the animation.
/// </param>
/// <param name="amount">
/// A <see cref="Vector3"/> for the amount of change in position to move the
GameObject.
/// </param>
/// <param name="time">
/// A <see cref="System.Single"/> for the time in seconds the animation will
take to complete.
/// </param>
public static void MoveBy( GameObject target, Vector3 amount, float time ) {
MoveBy( target, Hash( "amount", amount, "time", time ) );
}
/// <summary>
/// Adds the supplied coordinates to a GameObject's position with FULL
customization options.
/// </summary>
/// <param name="amount">
/// A <see cref="Vector3"/> for the amount of change in position to move the
GameObject.
/// </param>
/// <param name="x">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
individual setting of the x axis.
/// </param>
/// <param name="y">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
individual setting of the y axis.
/// </param>
/// <param name="z">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
individual setting of the z axis.
/// </param>
/// <param name="orienttopath">
/// A <see cref="System.Boolean"/> for whether or not the GameObject will
orient to its direction of travel. False by default.
/// </param>
/// <param name="looktarget">
/// A <see cref="Vector3"/> or A <see cref="Transform"/> for a target the
GameObject will look at.
/// </param>
/// <param name="looktime">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time
in seconds the object will take to look at either the "looktarget" or
"orienttopath".
/// </param>
/// <param name="axis">
/// A <see cref="System.String"/>. Restricts rotation to the supplied axis
only.
/// </param>
/// <param name="space">
/// A <see cref="Space"/> or <see cref="System.String"/> for applying the
transformation in either the world coordinate or local cordinate system. Defaults
to local space.
/// </param>
/// <param name="time">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time
in seconds the animation will take to complete.
/// </param>
/// <param name="speed">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> can be used
instead of time to allow animation based on speed
/// </param>
/// <param name="delay">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time
in seconds the animation will wait before beginning.
/// </param>
/// <param name="easetype">
/// A <see cref="EaseType"/> or <see cref="System.String"/> for the shape of
the easing curve applied to the animation.
/// </param>
/// <param name="looptype">
/// A <see cref="LoopType"/> or <see cref="System.String"/> for the type of
loop to apply once the animation has completed.
/// </param>
/// <param name="onstart">
/// A <see cref="System.String"/> for the name of a function to launch at the
beginning of the animation.
/// </param>
/// <param name="onstarttarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "onstart" method.
/// </param>
/// <param name="onstartparams">
/// A <see cref="System.Object"/> for arguments to be sent to the "onstart"
method.
/// </param>
/// <param name="onupdate">
/// A <see cref="System.String"/> for the name of a function to launch on
every step of the animation.
/// </param>
/// <param name="onupdatetarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "onupdate" method.
/// </param>
/// <param name="onupdateparams">
/// A <see cref="System.Object"/> for arguments to be sent to the "onupdate"
method.
/// </param>
/// <param name="oncomplete">
/// A <see cref="System.String"/> for the name of a function to launch at the
end of the animation.
/// </param>
/// <param name="oncompletetarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "oncomplete" method.
/// </param>
/// <param name="oncompleteparams">
/// A <see cref="System.Object"/> for arguments to be sent to the
"oncomplete" method.
/// </param>
public static void MoveBy( GameObject target, Hashtable args ) {
//clean args:
args = iTween.CleanArgs( args );
//establish iTween:
args[ "type" ] = "move";
args[ "method" ] = "by";
Launch( target, args );
}
/// <summary>
/// Changes a GameObject's scale over time with MINIMUM customization
options.
/// </summary>
/// <param name="target">
/// A <see cref="GameObject"/> to be the target of the animation.
/// </param>
/// <param name="scale">
/// A <see cref="Vector3"/> for the final scale.
/// </param>
/// <param name="time">
/// A <see cref="System.Single"/> for the time in seconds the animation will
take to complete.
/// </param>
public static void ScaleTo( GameObject target, Vector3 scale, float time ) {
ScaleTo( target, Hash( "scale", scale, "time", time ) );
}
/// <summary>
/// Changes a GameObject's scale over time with FULL customization options.
/// </summary>
/// <param name="scale">
/// A <see cref="Transform"/> or <see cref="Vector3"/> for the final scale.
/// </param>
/// <param name="x">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
individual setting of the x axis.
/// </param>
/// <param name="y">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
individual setting of the y axis.
/// </param>
/// <param name="z">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
individual setting of the z axis.
/// </param>
/// <param name="time">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time
in seconds the animation will take to complete.
/// </param>
/// <param name="speed">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> can be used
instead of time to allow animation based on speed
/// </param>
/// <param name="delay">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time
in seconds the animation will wait before beginning.
/// </param>
/// <param name="easetype">
/// A <see cref="EaseType"/> or <see cref="System.String"/> for the shape of
the easing curve applied to the animation.
/// </param>
/// <param name="looptype">
/// A <see cref="LoopType"/> or <see cref="System.String"/> for the type of
loop to apply once the animation has completed.
/// </param>
/// <param name="onstart">
/// A <see cref="System.String"/> for the name of a function to launch at the
beginning of the animation.
/// </param>
/// <param name="onstarttarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "onstart" method.
/// </param>
/// <param name="onstartparams">
/// A <see cref="System.Object"/> for arguments to be sent to the "onstart"
method.
/// </param>
/// <param name="onupdate">
/// A <see cref="System.String"/> for the name of a function to launch on
every step of the animation.
/// </param>
/// <param name="onupdatetarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "onupdate" method.
/// </param>
/// <param name="onupdateparams">
/// A <see cref="System.Object"/> for arguments to be sent to the "onupdate"
method.
/// </param>
/// <param name="oncomplete">
/// A <see cref="System.String"/> for the name of a function to launch at the
end of the animation.
/// </param>
/// <param name="oncompletetarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "oncomplete" method.
/// </param>
/// <param name="oncompleteparams">
/// A <see cref="System.Object"/> for arguments to be sent to the
"oncomplete" method.
/// </param>
public static void ScaleTo( GameObject target, Hashtable args ) {
//clean args:
args = iTween.CleanArgs( args );
//establish iTween:
args[ "type" ] = "scale";
args[ "method" ] = "to";
Launch( target, args );
}
/// <summary>
/// Instantly changes a GameObject's scale then returns it to it's starting
scale over time with MINIMUM customization options.
/// </summary>
/// <param name="target">
/// A <see cref="GameObject"/> to be the target of the animation.
/// </param>
/// <param name="scale">
/// A <see cref="Vector3"/> for the final scale.
/// </param>
/// <param name="time">
/// A <see cref="System.Single"/> for the time in seconds the animation will
take to complete.
/// </param>
public static void ScaleFrom( GameObject target, Vector3 scale, float time )
{
ScaleFrom( target, Hash( "scale", scale, "time", time ) );
}
/// <summary>
/// Instantly changes a GameObject's scale then returns it to it's starting
scale over time with FULL customization options.
/// </summary>
/// <param name="scale">
/// A <see cref="Transform"/> or <see cref="Vector3"/> for the final scale.
/// </param>
/// <param name="x">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
individual setting of the x axis.
/// </param>
/// <param name="y">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
individual setting of the y axis.
/// </param>
/// <param name="z">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
individual setting of the z axis.
/// </param>
/// <param name="time">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time
in seconds the animation will take to complete.
/// </param>
/// <param name="speed">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> can be used
instead of time to allow animation based on speed
/// </param>
/// <param name="delay">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time
in seconds the animation will wait before beginning.
/// </param>
/// <param name="easetype">
/// A <see cref="EaseType"/> or <see cref="System.String"/> for the shape of
the easing curve applied to the animation.
/// </param>
/// <param name="looptype">
/// A <see cref="LoopType"/> or <see cref="System.String"/> for the type of
loop to apply once the animation has completed.
/// </param>
/// <param name="onstart">
/// A <see cref="System.String"/> for the name of a function to launch at the
beginning of the animation.
/// </param>
/// <param name="onstarttarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "onstart" method.
/// </param>
/// <param name="onstartparams">
/// A <see cref="System.Object"/> for arguments to be sent to the "onstart"
method.
/// </param>
/// <param name="onupdate">
/// A <see cref="System.String"/> for the name of a function to launch on
every step of the animation.
/// </param>
/// <param name="onupdatetarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "onupdate" method.
/// </param>
/// <param name="onupdateparams">
/// A <see cref="System.Object"/> for arguments to be sent to the "onupdate"
method.
/// </param>
/// <param name="oncomplete">
/// A <see cref="System.String"/> for the name of a function to launch at the
end of the animation.
/// </param>
/// <param name="oncompletetarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "oncomplete" method.
/// </param>
/// <param name="oncompleteparams">
/// A <see cref="System.Object"/> for arguments to be sent to the
"oncomplete" method.
/// </param>
public static void ScaleFrom( GameObject target, Hashtable args ) {
Vector3 tempScale;
Vector3 fromScale;
//clean args:
args = iTween.CleanArgs( args );
//apply fromScale:
target.transform.localScale = fromScale;
//establish iTween:
args[ "type" ] = "scale";
args[ "method" ] = "to";
Launch( target, args );
}
/// <summary>
/// Adds to a GameObject's scale over time with FULL customization options.
/// </summary>
/// <param name="target">
/// A <see cref="GameObject"/> to be the target of the animation.
/// </param>
/// <param name="amount">
/// A <see cref="Vector3"/> for the amount of scale to be added to the
GameObject's current scale.
/// </param>
/// <param name="time">
/// A <see cref="System.Single"/> for the time in seconds the animation will
take to complete.
/// </param>
public static void ScaleAdd( GameObject target, Vector3 amount, float time )
{
ScaleAdd( target, Hash( "amount", amount, "time", time ) );
}
/// <summary>
/// Adds to a GameObject's scale over time with FULL customization options.
/// </summary>
/// <param name="amount">
/// A <see cref="Vector3"/> for the amount to be added to the GameObject's
current scale.
/// </param>
/// <param name="x">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
individual setting of the x axis.
/// </param>
/// <param name="y">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
individual setting of the y axis.
/// </param>
/// <param name="z">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
individual setting of the z axis.
/// </param>
/// <param name="time">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time
in seconds the animation will take to complete.
/// </param>
/// <param name="speed">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> can be used
instead of time to allow animation based on speed
/// </param>
/// <param name="delay">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time
in seconds the animation will wait before beginning.
/// </param>
/// <param name="easetype">
/// A <see cref="EaseType"/> or <see cref="System.String"/> for the shape of
the easing curve applied to the animation.
/// </param>
/// <param name="looptype">
/// A <see cref="LoopType"/> or <see cref="System.String"/> for the type of
loop to apply once the animation has completed.
/// </param>
/// <param name="onstart">
/// A <see cref="System.String"/> for the name of a function to launch at the
beginning of the animation.
/// </param>
/// <param name="onstarttarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "onstart" method.
/// </param>
/// <param name="onstartparams">
/// A <see cref="System.Object"/> for arguments to be sent to the "onstart"
method.
/// </param>
/// <param name="onupdate">
/// A <see cref="System.String"/> for the name of a function to launch on
every step of the animation.
/// </param>
/// <param name="onupdatetarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "onupdate" method.
/// </param>
/// <param name="onupdateparams">
/// A <see cref="System.Object"/> for arguments to be sent to the "onupdate"
method.
/// </param>
/// <param name="oncomplete">
/// A <see cref="System.String"/> for the name of a function to launch at the
end of the animation.
/// </param>
/// <param name="oncompletetarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "oncomplete" method.
/// </param>
/// <param name="oncompleteparams">
/// A <see cref="System.Object"/> for arguments to be sent to the
"oncomplete" method.
/// </param>
public static void ScaleAdd( GameObject target, Hashtable args ) {
//clean args:
args = iTween.CleanArgs( args );
//establish iTween:
args[ "type" ] = "scale";
args[ "method" ] = "add";
Launch( target, args );
}
/// <summary>
/// Multiplies a GameObject's scale over time with MINIMUM customization
options.
/// </summary>
/// <param name="target">
/// A <see cref="GameObject"/> to be the target of the animation.
/// </param>
/// <param name="amount">
/// A <see cref="Vector3"/> for the amount of scale to be multiplied by the
GameObject's current scale.
/// </param>
/// <param name="time">
/// A <see cref="System.Single"/> for the time in seconds the animation will
take to complete.
/// </param>
public static void ScaleBy( GameObject target, Vector3 amount, float time ) {
ScaleBy( target, Hash( "amount", amount, "time", time ) );
}
/// <summary>
/// Multiplies a GameObject's scale over time with FULL customization
options.
/// </summary>
/// <param name="amount">
/// A <see cref="Vector3"/> for the amount to be multiplied to the
GameObject's current scale.
/// </param>
/// <param name="x">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
individual setting of the x axis.
/// </param>
/// <param name="y">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
individual setting of the y axis.
/// </param>
/// <param name="z">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
individual setting of the z axis.
/// </param>
/// <param name="time">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time
in seconds the animation will take to complete.
/// </param>
/// <param name="speed">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> can be used
instead of time to allow animation based on speed
/// </param>
/// <param name="delay">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time
in seconds the animation will wait before beginning.
/// </param>
/// <param name="easetype">
/// A <see cref="EaseType"/> or <see cref="System.String"/> for the shape of
the easing curve applied to the animation.
/// </param>
/// <param name="looptype">
/// A <see cref="LoopType"/> or <see cref="System.String"/> for the type of
loop to apply once the animation has completed.
/// </param>
/// <param name="onstart">
/// A <see cref="System.String"/> for the name of a function to launch at the
beginning of the animation.
/// </param>
/// <param name="onstarttarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "onstart" method.
/// </param>
/// <param name="onstartparams">
/// A <see cref="System.Object"/> for arguments to be sent to the "onstart"
method.
/// </param>
/// <param name="onupdate">
/// A <see cref="System.String"/> for the name of a function to launch on
every step of the animation.
/// </param>
/// <param name="onupdatetarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "onupdate" method.
/// </param>
/// <param name="onupdateparams">
/// A <see cref="System.Object"/> for arguments to be sent to the "onupdate"
method.
/// </param>
/// <param name="oncomplete">
/// A <see cref="System.String"/> for the name of a function to launch at the
end of the animation.
/// </param>
/// <param name="oncompletetarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "oncomplete" method.
/// </param>
/// <param name="oncompleteparams">
/// A <see cref="System.Object"/> for arguments to be sent to the
"oncomplete" method.
/// </param>
public static void ScaleBy( GameObject target, Hashtable args ) {
//clean args:
args = iTween.CleanArgs( args );
//establish iTween:
args[ "type" ] = "scale";
args[ "method" ] = "by";
Launch( target, args );
}
/// <summary>
/// Rotates a GameObject to the supplied Euler angles in degrees over time
with MINIMUM customization options.
/// </summary>
/// <param name="target">
/// A <see cref="GameObject"/> to be the target of the animation.
/// </param>
/// <param name="rotation">
/// A <see cref="Vector3"/> for the target Euler angles in degrees to rotate
to.
/// </param>
/// <param name="time">
/// A <see cref="System.Single"/> for the time in seconds the animation will
take to complete.
/// </param>
public static void RotateTo( GameObject target, Vector3 rotation, float
time ) {
RotateTo( target, Hash( "rotation", rotation, "time", time ) );
}
/// <summary>
/// Rotates a GameObject to the supplied Euler angles in degrees over time
with FULL customization options.
/// </summary>
/// <param name="rotation">
/// A <see cref="Transform"/> or <see cref="Vector3"/> for the target Euler
angles in degrees to rotate to.
/// </param>
/// <param name="x">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
individual setting of the x axis.
/// </param>
/// <param name="y">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
individual setting of the y axis.
/// </param>
/// <param name="z">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
individual setting of the z axis.
/// </param>
/// <param name="islocal">
/// A <see cref="System.Boolean"/> for whether to animate in world space or
relative to the parent. False by default.
/// </param>
/// <param name="time">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time
in seconds the animation will take to complete.
/// </param>
/// <param name="speed">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> can be used
instead of time to allow animation based on speed
/// </param>
/// <param name="delay">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time
in seconds the animation will wait before beginning.
/// </param>
/// <param name="easetype">
/// A <see cref="EaseType"/> or <see cref="System.String"/> for the shape of
the easing curve applied to the animation.
/// </param>
/// <param name="looptype">
/// A <see cref="LoopType"/> or <see cref="System.String"/> for the type of
loop to apply once the animation has completed.
/// </param>
/// <param name="onstart">
/// A <see cref="System.String"/> for the name of a function to launch at the
beginning of the animation.
/// </param>
/// <param name="onstarttarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "onstart" method.
/// </param>
/// <param name="onstartparams">
/// A <see cref="System.Object"/> for arguments to be sent to the "onstart"
method.
/// </param>
/// <param name="onupdate">
/// A <see cref="System.String"/> for the name of a function to launch on
every step of the animation.
/// </param>
/// <param name="onupdatetarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "onupdate" method.
/// </param>
/// <param name="onupdateparams">
/// A <see cref="System.Object"/> for arguments to be sent to the "onupdate"
method.
/// </param>
/// <param name="oncomplete">
/// A <see cref="System.String"/> for the name of a function to launch at the
end of the animation.
/// </param>
/// <param name="oncompletetarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "oncomplete" method.
/// </param>
/// <param name="oncompleteparams">
/// A <see cref="System.Object"/> for arguments to be sent to the
"oncomplete" method.
/// </param>
public static void RotateTo( GameObject target, Hashtable args ) {
//clean args:
args = iTween.CleanArgs( args );
//establish iTween
args[ "type" ] = "rotate";
args[ "method" ] = "to";
Launch( target, args );
}
/// <summary>
/// Instantly changes a GameObject's Euler angles in degrees then returns it
to it's starting rotation over time (if allowed) with MINIMUM customization
options.
/// </summary>
/// <param name="target">
/// A <see cref="GameObject"/> to be the target of the animation.
/// </param>
/// <param name="rotation">
/// A <see cref="Vector3"/> for the target Euler angles in degrees to rotate
from.
/// </param>
/// <param name="time">
/// A <see cref="System.Single"/> for the time in seconds the animation will
take to complete.
/// </param>
public static void RotateFrom( GameObject target, Vector3 rotation, float
time ) {
RotateFrom( target, Hash( "rotation", rotation, "time", time ) );
}
/// <summary>
/// Instantly changes a GameObject's Euler angles in degrees then returns it
to it's starting rotation over time (if allowed) with FULL customization options.
/// </summary>
/// <param name="rotation">
/// A <see cref="Transform"/> or <see cref="Vector3"/> for the target Euler
angles in degrees to rotate to.
/// </param>
/// <param name="x">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
individual setting of the x axis.
/// </param>
/// <param name="y">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
individual setting of the y axis.
/// </param>
/// <param name="z">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
individual setting of the z axis.
/// </param>
/// <param name="islocal">
/// A <see cref="System.Boolean"/> for whether to animate in world space or
relative to the parent. False by default.
/// </param>
/// <param name="time">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time
in seconds the animation will take to complete.
/// </param>
/// <param name="speed">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> can be used
instead of time to allow animation based on speed
/// </param>
/// <param name="delay">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time
in seconds the animation will wait before beginning.
/// </param>
/// <param name="easetype">
/// A <see cref="EaseType"/> or <see cref="System.String"/> for the shape of
the easing curve applied to the animation.
/// </param>
/// <param name="looptype">
/// A <see cref="LoopType"/> or <see cref="System.String"/> for the type of
loop to apply once the animation has completed.
/// </param>
/// <param name="onstart">
/// A <see cref="System.String"/> for the name of a function to launch at the
beginning of the animation.
/// </param>
/// <param name="onstarttarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "onstart" method.
/// </param>
/// <param name="onstartparams">
/// A <see cref="System.Object"/> for arguments to be sent to the "onstart"
method.
/// </param>
/// <param name="onupdate">
/// A <see cref="System.String"/> for the name of a function to launch on
every step of the animation.
/// </param>
/// <param name="onupdatetarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "onupdate" method.
/// </param>
/// <param name="onupdateparams">
/// A <see cref="System.Object"/> for arguments to be sent to the "onupdate"
method.
/// </param>
/// <param name="oncomplete">
/// A <see cref="System.String"/> for the name of a function to launch at the
end of the animation.
/// </param>
/// <param name="oncompletetarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "oncomplete" method.
/// </param>
/// <param name="oncompleteparams">
/// A <see cref="System.Object"/> for arguments to be sent to the
"oncomplete" method.
/// </param>
public static void RotateFrom( GameObject target, Hashtable args ) {
Vector3 tempRotation;
Vector3 fromRotation;
bool tempIsLocal;
//clean args:
args = iTween.CleanArgs( args );
//set tempIsLocal:
if ( args.Contains( "islocal" ) ) {
tempIsLocal = (bool)args[ "islocal" ];
} else {
tempIsLocal = Defaults.isLocal;
}
//apply fromRotation:
if ( tempIsLocal ) {
target.transform.localEulerAngles = fromRotation;
} else {
target.transform.eulerAngles = fromRotation;
}
//establish iTween:
args[ "type" ] = "rotate";
args[ "method" ] = "to";
Launch( target, args );
}
/// <summary>
/// Adds supplied Euler angles in degrees to a GameObject's rotation over
time with MINIMUM customization options.
/// </summary>
/// <param name="target">
/// A <see cref="GameObject"/> to be the target of the animation.
/// </param>
/// <param name="amount">
/// A <see cref="Vector3"/> for the amount of Euler angles in degrees to add
to the current rotation of the GameObject.
/// </param>
/// <param name="time">
/// A <see cref="System.Single"/> for the time in seconds the animation will
take to complete.
/// </param>
public static void RotateAdd( GameObject target, Vector3 amount, float time )
{
RotateAdd( target, Hash( "amount", amount, "time", time ) );
}
/// <summary>
/// Adds supplied Euler angles in degrees to a GameObject's rotation over
time with FULL customization options.
/// </summary>
/// <param name="amount">
/// A <see cref="Vector3"/> for the amount of Euler angles in degrees to add
to the current rotation of the GameObject.
/// </param>
/// <param name="x">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
individual setting of the x axis.
/// </param>
/// <param name="y">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
individual setting of the y axis.
/// </param>
/// <param name="z">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
individual setting of the z axis.
/// </param>
/// <param name="space">
/// A <see cref="Space"/> or <see cref="System.String"/> for applying the
transformation in either the world coordinate or local cordinate system. Defaults
to local space.
/// </param>
/// <param name="time">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time
in seconds the animation will take to complete.
/// </param>
/// <param name="speed">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> can be used
instead of time to allow animation based on speed
/// </param>
/// <param name="delay">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time
in seconds the animation will wait before beginning.
/// </param>
/// <param name="easetype">
/// A <see cref="EaseType"/> or <see cref="System.String"/> for the shape of
the easing curve applied to the animation.
/// </param>
/// <param name="looptype">
/// A <see cref="LoopType"/> or <see cref="System.String"/> for the type of
loop to apply once the animation has completed.
/// </param>
/// <param name="onstart">
/// A <see cref="System.String"/> for the name of a function to launch at the
beginning of the animation.
/// </param>
/// <param name="onstarttarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "onstart" method.
/// </param>
/// <param name="onstartparams">
/// A <see cref="System.Object"/> for arguments to be sent to the "onstart"
method.
/// </param>
/// <param name="onupdate">
/// A <see cref="System.String"/> for the name of a function to launch on
every step of the animation.
/// </param>
/// <param name="onupdatetarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "onupdate" method.
/// </param>
/// <param name="onupdateparams">
/// A <see cref="System.Object"/> for arguments to be sent to the "onupdate"
method.
/// </param>
/// <param name="oncomplete">
/// A <see cref="System.String"/> for the name of a function to launch at the
end of the animation.
/// </param>
/// <param name="oncompletetarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "oncomplete" method.
/// </param>
/// <param name="oncompleteparams">
/// A <see cref="System.Object"/> for arguments to be sent to the
"oncomplete" method.
/// </param>
public static void RotateAdd( GameObject target, Hashtable args ) {
//clean args:
args = iTween.CleanArgs( args );
//establish iTween:
args[ "type" ] = "rotate";
args[ "method" ] = "add";
Launch( target, args );
}
/// <summary>
/// Multiplies supplied values by 360 and rotates a GameObject by calculated
amount over time with MINIMUM customization options.
/// </summary>
/// <param name="target">
/// A <see cref="GameObject"/> to be the target of the animation.
/// </param>
/// <param name="amount">
/// A <see cref="Vector3"/> for the amount to be multiplied by 360 to rotate
the GameObject.
/// </param>
/// <param name="time">
/// A <see cref="System.Single"/> for the time in seconds the animation will
take to complete.
/// </param>
public static void RotateBy( GameObject target, Vector3 amount, float time )
{
RotateBy( target, Hash( "amount", amount, "time", time ) );
}
/// <summary>
/// Multiplies supplied values by 360 and rotates a GameObject by calculated
amount over time with FULL customization options.
/// </summary>
/// <param name="amount">
/// A <see cref="Vector3"/> for the amount to be multiplied by 360 to rotate
the GameObject.
/// </param>
/// <param name="x">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
individual setting of the x axis.
/// </param>
/// <param name="y">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
individual setting of the y axis.
/// </param>
/// <param name="z">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
individual setting of the z axis.
/// </param>
/// <param name="space">
/// A <see cref="Space"/> or <see cref="System.String"/> for applying the
transformation in either the world coordinate or local cordinate system. Defaults
to local space.
/// </param>
/// <param name="islocal">
/// A <see cref="System.Boolean"/> for whether to animate in world space or
relative to the parent. False by default.
/// </param>
/// <param name="time">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time
in seconds the animation will take to complete.
/// </param>
/// <param name="speed">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> can be used
instead of time to allow animation based on speed
/// </param>
/// <param name="delay">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time
in seconds the animation will wait before beginning.
/// </param>
/// <param name="easetype">
/// A <see cref="EaseType"/> or <see cref="System.String"/> for the shape of
the easing curve applied to the animation.
/// </param>
/// <param name="looptype">
/// A <see cref="LoopType"/> or <see cref="System.String"/> for the type of
loop to apply once the animation has completed.
/// </param>
/// <param name="onstart">
/// A <see cref="System.String"/> for the name of a function to launch at the
beginning of the animation.
/// </param>
/// <param name="onstarttarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "onstart" method.
/// </param>
/// <param name="onstartparams">
/// A <see cref="System.Object"/> for arguments to be sent to the "onstart"
method.
/// </param>
/// <param name="onupdate">
/// A <see cref="System.String"/> for the name of a function to launch on
every step of the animation.
/// </param>
/// <param name="onupdatetarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "onupdate" method.
/// </param>
/// <param name="onupdateparams">
/// A <see cref="System.Object"/> for arguments to be sent to the "onupdate"
method.
/// </param>
/// <param name="oncomplete">
/// A <see cref="System.String"/> for the name of a function to launch at the
end of the animation.
/// </param>
/// <param name="oncompletetarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "oncomplete" method.
/// </param>
/// <param name="oncompleteparams">
/// A <see cref="System.Object"/> for arguments to be sent to the
"oncomplete" method.
/// </param>
public static void RotateBy( GameObject target, Hashtable args ) {
//clean args:
args = iTween.CleanArgs( args );
//establish iTween
args[ "type" ] = "rotate";
args[ "method" ] = "by";
Launch( target, args );
}
/// <summary>
/// Randomly shakes a GameObject's position by a diminishing amount over time
with MINIMUM customization options.
/// </summary>
/// <param name="target">
/// A <see cref="GameObject"/> to be the target of the animation.
/// </param>
/// <param name="amount">
/// A <see cref="Vector3"/> for the magnitude of shake.
/// </param>
/// <param name="time">
/// A <see cref="System.Single"/> for the time in seconds the animation will
take to complete.
/// </param>
public static void ShakePosition( GameObject target, Vector3 amount, float
time ) {
ShakePosition( target, Hash( "amount", amount, "time", time ) );
}
/// <summary>
/// Randomly shakes a GameObject's position by a diminishing amount over time
with FULL customization options.
/// </summary>
/// <param name="amount">
/// A <see cref="Vector3"/> for the magnitude of shake.
/// </param>
/// <param name="x">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
individual setting of the x magnitude.
/// </param>
/// <param name="y">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
individual setting of the y magnitude.
/// </param>
/// <param name="z">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
individual setting of the z magnitude.
/// </param>
/// <param name="islocal">
/// A <see cref="System.Boolean"/> for whether to animate in world space or
relative to the parent. False by default.
/// </param>
/// <param name="orienttopath">
/// A <see cref="System.Boolean"/> for whether or not the GameObject will
orient to its direction of travel. False by default.
/// </param>
/// <param name="looktarget">
/// A <see cref="Vector3"/> or A <see cref="Transform"/> for a target the
GameObject will look at.
/// </param>
/// <param name="looktime">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time
in seconds the object will take to look at either the "looktarget" or
"orienttopath".
/// </param>
/// <param name="time">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time
in seconds the animation will take to complete.
/// </param>
/// <param name="delay">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time
in seconds the animation will wait before beginning.
/// </param>
/// <param name="looptype">
/// A <see cref="LoopType"/> or <see cref="System.String"/> for the type of
loop to apply once the animation has completed. (only "loop" is allowed with
shakes)
/// </param>
/// <param name="onstart">
/// A <see cref="System.String"/> for the name of a function to launch at the
beginning of the animation.
/// </param>
/// <param name="onstarttarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "onstart" method.
/// </param>
/// <param name="onstartparams">
/// A <see cref="System.Object"/> for arguments to be sent to the "onstart"
method.
/// </param>
/// <param name="onupdate">
/// A <see cref="System.String"/> for the name of a function to launch on
every step of the animation.
/// </param>
/// <param name="onupdatetarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "onupdate" method.
/// </param>
/// <param name="onupdateparams">
/// A <see cref="System.Object"/> for arguments to be sent to the "onupdate"
method.
/// </param>
/// <param name="oncomplete">
/// A <see cref="System.String"/> for the name of a function to launch at the
end of the animation.
/// </param>
/// <param name="oncompletetarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "oncomplete" method.
/// </param>
/// <param name="oncompleteparams">
/// A <see cref="System.Object"/> for arguments to be sent to the
"oncomplete" method.
/// </param>
public static void ShakePosition( GameObject target, Hashtable args ) {
//clean args:
args = iTween.CleanArgs( args );
//establish iTween
args[ "type" ] = "shake";
args[ "method" ] = "position";
Launch( target, args );
}
/// <summary>
/// Randomly shakes a GameObject's scale by a diminishing amount over time
with MINIMUM customization options.
/// </summary>
/// <param name="target">
/// A <see cref="GameObject"/> to be the target of the animation.
/// </param>
/// <param name="amount">
/// A <see cref="Vector3"/> for the magnitude of shake.
/// </param>
/// <param name="time">
/// A <see cref="System.Single"/> for the time in seconds the animation will
take to complete.
/// </param>
public static void ShakeScale( GameObject target, Vector3 amount, float
time ) {
ShakeScale( target, Hash( "amount", amount, "time", time ) );
}
/// <summary>
/// Randomly shakes a GameObject's scale by a diminishing amount over time
with FULL customization options.
/// </summary>
/// <param name="amount">
/// A <see cref="Vector3"/> for the magnitude of shake.
/// </param>
/// <param name="x">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
individual setting of the x magnitude.
/// </param>
/// <param name="y">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
individual setting of the y magnitude.
/// </param>
/// <param name="z">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
individual setting of the z magnitude.
/// </param>
/// <param name="time">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time
in seconds the animation will take to complete.
/// </param>
/// <param name="delay">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time
in seconds the animation will wait before beginning.
/// </param>
/// <param name="looptype">
/// A <see cref="LoopType"/> or <see cref="System.String"/> for the type of
loop to apply once the animation has completed. (only "loop" is allowed with
shakes)
/// </param>
/// <param name="onstart">
/// A <see cref="System.String"/> for the name of a function to launch at the
beginning of the animation.
/// </param>
/// <param name="onstarttarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "onstart" method.
/// </param>
/// <param name="onstartparams">
/// A <see cref="System.Object"/> for arguments to be sent to the "onstart"
method.
/// </param>
/// <param name="onupdate">
/// A <see cref="System.String"/> for the name of a function to launch on
every step of the animation.
/// </param>
/// <param name="onupdatetarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "onupdate" method.
/// </param>
/// <param name="onupdateparams">
/// A <see cref="System.Object"/> for arguments to be sent to the "onupdate"
method.
/// </param>
/// <param name="oncomplete">
/// A <see cref="System.String"/> for the name of a function to launch at the
end of the animation.
/// </param>
/// <param name="oncompletetarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "oncomplete" method.
/// </param>
/// <param name="oncompleteparams">
/// A <see cref="System.Object"/> for arguments to be sent to the
"oncomplete" method.
/// </param>
public static void ShakeScale( GameObject target, Hashtable args ) {
//clean args:
args = iTween.CleanArgs( args );
//establish iTween
args[ "type" ] = "shake";
args[ "method" ] = "scale";
Launch( target, args );
}
/// <summary>
/// Randomly shakes a GameObject's rotation by a diminishing amount over time
with MINIMUM customization options.
/// </summary>
/// <param name="target">
/// A <see cref="GameObject"/> to be the target of the animation.
/// </param>
/// <param name="amount">
/// A <see cref="Vector3"/> for the magnitude of shake.
/// </param>
/// <param name="time">
/// A <see cref="System.Single"/> for the time in seconds the animation will
take to complete.
/// </param>
public static void ShakeRotation( GameObject target, Vector3 amount, float
time ) {
ShakeRotation( target, Hash( "amount", amount, "time", time ) );
}
/// <summary>
/// Randomly shakes a GameObject's rotation by a diminishing amount over time
with FULL customization options.
/// </summary>
/// <param name="amount">
/// A <see cref="Vector3"/> for the magnitude of shake.
/// </param>
/// <param name="x">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
individual setting of the x magnitude.
/// </param>
/// <param name="y">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
individual setting of the y magnitude.
/// </param>
/// <param name="z">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
individual setting of the z magnitude.
/// </param>
/// <param name="space">
/// A <see cref="Space"/> for applying the transformation in either the world
coordinate or local cordinate system. Defaults to local space.
/// </param>
/// <param name="time">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time
in seconds the animation will take to complete.
/// </param>
/// <param name="delay">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time
in seconds the animation will wait before beginning.
/// </param>
/// <param name="looptype">
/// A <see cref="LoopType"/> or <see cref="System.String"/> for the type of
loop to apply once the animation has completed. (only "loop" is allowed with
shakes)
/// </param>
/// <param name="onstart">
/// A <see cref="System.String"/> for the name of a function to launch at the
beginning of the animation.
/// </param>
/// <param name="onstarttarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "onstart" method.
/// </param>
/// <param name="onstartparams">
/// A <see cref="System.Object"/> for arguments to be sent to the "onstart"
method.
/// </param>
/// <param name="onupdate">
/// A <see cref="System.String"/> for the name of a function to launch on
every step of the animation.
/// </param>
/// <param name="onupdatetarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "onupdate" method.
/// </param>
/// <param name="onupdateparams">
/// A <see cref="System.Object"/> for arguments to be sent to the "onupdate"
method.
/// </param>
/// <param name="oncomplete">
/// A <see cref="System.String"/> for the name of a function to launch at the
end of the animation.
/// </param>
/// <param name="oncompletetarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "oncomplete" method.
/// </param>
/// <param name="oncompleteparams">
/// A <see cref="System.Object"/> for arguments to be sent to the
"oncomplete" method.
/// </param>
public static void ShakeRotation( GameObject target, Hashtable args ) {
//clean args:
args = iTween.CleanArgs( args );
//establish iTween
args[ "type" ] = "shake";
args[ "method" ] = "rotation";
Launch( target, args );
}
/// <summary>
/// Applies a jolt of force to a GameObject's position and wobbles it back to
its initial position with MINIMUM customization options.
/// </summary>
/// <param name="target">
/// A <see cref="GameObject"/> to be the target of the animation.
/// </param>
/// <param name="amount">
/// A <see cref="Vector3"/> for the magnitude of the punch.
/// </param>
/// <param name="time">
/// A <see cref="System.Single"/> for the time in seconds the animation will
take to complete.
/// </param>
public static void PunchPosition( GameObject target, Vector3 amount, float
time ) {
PunchPosition( target, Hash( "amount", amount, "time", time ) );
}
/// <summary>
/// Applies a jolt of force to a GameObject's position and wobbles it back to
its initial position with FULL customization options.
/// </summary>
/// <param name="amount">
/// A <see cref="Vector3"/> for the magnitude of shake.
/// </param>
/// <param name="x">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
individual setting of the x magnitude.
/// </param>
/// <param name="y">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
individual setting of the y magnitude.
/// </param>
/// <param name="z">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
individual setting of the z magnitude.
/// </param>
/// <param name="space">
/// A <see cref="Space"/> for applying the transformation in either the world
coordinate or local cordinate system. Defaults to local space.
/// </param>
/// <param name="looktarget">
/// A <see cref="Vector3"/> or A <see cref="Transform"/> for a target the
GameObject will look at.
/// </param>
/// <param name="looktime">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time
in seconds the object will take to look at either the "looktarget".
/// </param>
/// <param name="time">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time
in seconds the animation will take to complete.
/// </param>
/// <param name="delay">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time
in seconds the animation will wait before beginning.
/// </param>
/// <param name="looptype">
/// A <see cref="LoopType"/> or <see cref="System.String"/> for the type of
loop to apply once the animation has completed. (only "loop" is allowed with
punches)
/// </param>
/// <param name="onstart">
/// A <see cref="System.String"/> for the name of a function to launch at the
beginning of the animation.
/// </param>
/// <param name="onstarttarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "onstart" method.
/// </param>
/// <param name="onstartparams">
/// A <see cref="System.Object"/> for arguments to be sent to the "onstart"
method.
/// </param>
/// <param name="onupdate">
/// A <see cref="System.String"/> for the name of a function to launch on
every step of the animation.
/// </param>
/// <param name="onupdatetarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "onupdate" method.
/// </param>
/// <param name="onupdateparams">
/// A <see cref="System.Object"/> for arguments to be sent to the "onupdate"
method.
/// </param>
/// <param name="oncomplete">
/// A <see cref="System.String"/> for the name of a function to launch at the
end of the animation.
/// </param>
/// <param name="oncompletetarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "oncomplete" method.
/// </param>
/// <param name="oncompleteparams">
/// A <see cref="System.Object"/> for arguments to be sent to the
"oncomplete" method.
/// </param>
public static void PunchPosition( GameObject target, Hashtable args ) {
//clean args:
args = iTween.CleanArgs( args );
//establish iTween
args[ "type" ] = "punch";
args[ "method" ] = "position";
args[ "easetype" ] = EaseType.punch;
Launch( target, args );
}
/// <summary>
/// Applies a jolt of force to a GameObject's rotation and wobbles it back to
its initial rotation with MINIMUM customization options.
/// </summary>
/// <param name="target">
/// A <see cref="GameObject"/> to be the target of the animation.
/// </param>
/// <param name="amount">
/// A <see cref="Vector3"/> for the magnitude of the punch.
/// </param>
/// <param name="time">
/// A <see cref="System.Single"/> for the time in seconds the animation will
take to complete.
/// </param>
public static void PunchRotation( GameObject target, Vector3 amount, float
time ) {
PunchRotation( target, Hash( "amount", amount, "time", time ) );
}
/// <summary>
/// Applies a jolt of force to a GameObject's rotation and wobbles it back to
its initial rotation with FULL customization options.
/// </summary>
/// <param name="amount">
/// A <see cref="Vector3"/> for the magnitude of shake.
/// </param>
/// <param name="x">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
individual setting of the x magnitude.
/// </param>
/// <param name="y">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
individual setting of the y magnitude.
/// </param>
/// <param name="z">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
individual setting of the z magnitude.
/// </param>
/// <param name="space">
/// A <see cref="Space"/> for applying the transformation in either the world
coordinate or local cordinate system. Defaults to local space.
/// </param>
/// <param name="time">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time
in seconds the animation will take to complete.
/// </param>
/// <param name="delay">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time
in seconds the animation will wait before beginning.
/// </param>
/// <param name="looptype">
/// A <see cref="LoopType"/> or <see cref="System.String"/> for the type of
loop to apply once the animation has completed. (only "loop" is allowed with
punches)
/// </param>
/// <param name="onstart">
/// A <see cref="System.String"/> for the name of a function to launch at the
beginning of the animation.
/// </param>
/// <param name="onstarttarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "onstart" method.
/// </param>
/// <param name="onstartparams">
/// A <see cref="System.Object"/> for arguments to be sent to the "onstart"
method.
/// </param>
/// <param name="onupdate">
/// A <see cref="System.String"/> for the name of a function to launch on
every step of the animation.
/// </param>
/// <param name="onupdatetarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "onupdate" method.
/// </param>
/// <param name="onupdateparams">
/// A <see cref="System.Object"/> for arguments to be sent to the "onupdate"
method.
/// </param>
/// <param name="oncomplete">
/// A <see cref="System.String"/> for the name of a function to launch at the
end of the animation.
/// </param>
/// <param name="oncompletetarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "oncomplete" method.
/// </param>
/// <param name="oncompleteparams">
/// A <see cref="System.Object"/> for arguments to be sent to the
"oncomplete" method.
/// </param>
public static void PunchRotation( GameObject target, Hashtable args ) {
//clean args:
args = iTween.CleanArgs( args );
//establish iTween
args[ "type" ] = "punch";
args[ "method" ] = "rotation";
args[ "easetype" ] = EaseType.punch;
Launch( target, args );
}
/// <summary>
/// Applies a jolt of force to a GameObject's scale and wobbles it back to
its initial scale with MINIMUM customization options.
/// </summary>
/// <param name="target">
/// A <see cref="GameObject"/> to be the target of the animation.
/// </param>
/// <param name="amount">
/// A <see cref="Vector3"/> for the magnitude of the punch.
/// </param>
/// <param name="time">
/// A <see cref="System.Single"/> for the time in seconds the animation will
take to complete.
/// </param>
public static void PunchScale( GameObject target, Vector3 amount, float
time ) {
PunchScale( target, Hash( "amount", amount, "time", time ) );
}
/// <summary>
/// Applies a jolt of force to a GameObject's scale and wobbles it back to
its initial scale with FULL customization options.
/// </summary>
/// <param name="amount">
/// A <see cref="Vector3"/> for the magnitude of shake.
/// </param>
/// <param name="x">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
individual setting of the x magnitude.
/// </param>
/// <param name="y">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
individual setting of the y magnitude.
/// </param>
/// <param name="z">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
individual setting of the z magnitude.
/// </param>
/// <param name="time">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time
in seconds the animation will take to complete.
/// </param>
/// <param name="delay">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time
in seconds the animation will wait before beginning.
/// </param>
/// <param name="looptype">
/// A <see cref="LoopType"/> or <see cref="System.String"/> for the type of
loop to apply once the animation has completed. (only "loop" is allowed with
punches)
/// </param>
/// <param name="onstart">
/// A <see cref="System.String"/> for the name of a function to launch at the
beginning of the animation.
/// </param>
/// <param name="onstarttarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "onstart" method.
/// </param>
/// <param name="onstartparams">
/// A <see cref="System.Object"/> for arguments to be sent to the "onstart"
method.
/// </param>
/// <param name="onupdate">
/// A <see cref="System.String"/> for the name of a function to launch on
every step of the animation.
/// </param>
/// <param name="onupdatetarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "onupdate" method.
/// </param>
/// <param name="onupdateparams">
/// A <see cref="System.Object"/> for arguments to be sent to the "onupdate"
method.
/// </param>
/// <param name="oncomplete">
/// A <see cref="System.String"/> for the name of a function to launch at the
end of the animation.
/// </param>
/// <param name="oncompletetarget">
/// A <see cref="GameObject"/> for a reference to the GameObject that holds
the "oncomplete" method.
/// </param>
/// <param name="oncompleteparams">
/// A <see cref="System.Object"/> for arguments to be sent to the
"oncomplete" method.
/// </param>
public static void PunchScale( GameObject target, Hashtable args ) {
//clean args:
args = iTween.CleanArgs( args );
//establish iTween
args[ "type" ] = "punch";
args[ "method" ] = "scale";
args[ "easetype" ] = EaseType.punch;
Launch( target, args );
}
#endregion
//call correct set target method and set tween application delegate:
void GenerateTargets() {
switch ( type ) {
case "value":
switch ( method ) {
case "float":
GenerateFloatTargets();
apply = new ApplyTween( ApplyFloatTargets );
break;
case "vector2":
GenerateVector2Targets();
apply = new ApplyTween( ApplyVector2Targets );
break;
case "vector3":
GenerateVector3Targets();
apply = new ApplyTween( ApplyVector3Targets );
break;
case "color":
GenerateColorTargets();
apply = new ApplyTween( ApplyColorTargets );
break;
case "rect":
GenerateRectTargets();
apply = new ApplyTween( ApplyRectTargets );
break;
}
break;
case "color":
switch ( method ) {
case "to":
GenerateColorToTargets();
apply = new ApplyTween( ApplyColorToTargets );
break;
}
break;
case "audio":
switch ( method ) {
case "to":
GenerateAudioToTargets();
apply = new ApplyTween( ApplyAudioToTargets );
break;
}
break;
case "move":
switch ( method ) {
case "to":
//using a path?
if ( tweenArguments.Contains( "path" ) ) {
GenerateMoveToPathTargets();
apply = new
ApplyTween( ApplyMoveToPathTargets );
} else { //not using a path?
GenerateMoveToTargets();
apply = new
ApplyTween( ApplyMoveToTargets );
}
break;
case "by":
case "add":
GenerateMoveByTargets();
apply = new ApplyTween( ApplyMoveByTargets );
break;
}
break;
case "scale":
switch ( method ) {
case "to":
GenerateScaleToTargets();
apply = new ApplyTween( ApplyScaleToTargets );
break;
case "by":
GenerateScaleByTargets();
apply = new ApplyTween( ApplyScaleToTargets );
break;
case "add":
GenerateScaleAddTargets();
apply = new ApplyTween( ApplyScaleToTargets );
break;
}
break;
case "rotate":
switch ( method ) {
case "to":
GenerateRotateToTargets();
apply = new ApplyTween( ApplyRotateToTargets );
break;
case "add":
GenerateRotateAddTargets();
apply = new
ApplyTween( ApplyRotateAddTargets );
break;
case "by":
GenerateRotateByTargets();
apply = new
ApplyTween( ApplyRotateAddTargets );
break;
}
break;
case "shake":
switch ( method ) {
case "position":
GenerateShakePositionTargets();
apply = new
ApplyTween( ApplyShakePositionTargets );
break;
case "scale":
GenerateShakeScaleTargets();
apply = new
ApplyTween( ApplyShakeScaleTargets );
break;
case "rotation":
GenerateShakeRotationTargets();
apply = new
ApplyTween( ApplyShakeRotationTargets );
break;
}
break;
case "punch":
switch ( method ) {
case "position":
GeneratePunchPositionTargets();
apply = new
ApplyTween( ApplyPunchPositionTargets );
break;
case "rotation":
GeneratePunchRotationTargets();
apply = new
ApplyTween( ApplyPunchRotationTargets );
break;
case "scale":
GeneratePunchScaleTargets();
apply = new
ApplyTween( ApplyPunchScaleTargets );
break;
}
break;
case "look":
switch ( method ) {
case "to":
GenerateLookToTargets();
apply = new ApplyTween( ApplyLookToTargets );
break;
}
break;
case "stab":
GenerateStabTargets();
apply = new ApplyTween( ApplyStabTargets );
break;
}
}
#endregion
void GenerateRectTargets() {
//values holder [0] from, [1] to, [2] calculated value from ease
equation:
rects = new Rect[ 3 ];
void GenerateColorTargets() {
//values holder [0] from, [1] to, [2] calculated value from ease
equation:
colors = new Color[ 1, 3 ];
void GenerateVector3Targets() {
//values holder [0] from, [1] to, [2] calculated value from ease
equation:
vector3s = new Vector3[ 3 ];
void GenerateVector2Targets() {
//values holder [0] from, [1] to, [2] calculated value from ease
equation:
vector2s = new Vector2[ 3 ];
void GenerateFloatTargets() {
//values holder [0] from, [1] to, [2] calculated value from ease
equation:
floats = new float[ 3 ];
void GenerateColorToTargets() {
//values holder [0] from, [1] to, [2] calculated value from ease
equation:
//colors = new Color[3];
//to values:
if ( tweenArguments.Contains( "color" ) ) {
//colors[1]=(Color)tweenArguments["color"];
for ( int i = 0; i < colors.GetLength( 0 ); i++ ) {
colors[ i, 1 ] = (Color)tweenArguments[ "color" ];
}
} else {
if ( tweenArguments.Contains( "r" ) ) {
//colors[1].r=(float)tweenArguments["r"];
for ( int i = 0; i < colors.GetLength( 0 ); i++ ) {
colors[ i, 1 ].r = (float)tweenArguments[ "r" ];
}
}
if ( tweenArguments.Contains( "g" ) ) {
//colors[1].g=(float)tweenArguments["g"];
for ( int i = 0; i < colors.GetLength( 0 ); i++ ) {
colors[ i, 1 ].g = (float)tweenArguments[ "g" ];
}
}
if ( tweenArguments.Contains( "b" ) ) {
//colors[1].b=(float)tweenArguments["b"];
for ( int i = 0; i < colors.GetLength( 0 ); i++ ) {
colors[ i, 1 ].b = (float)tweenArguments[ "b" ];
}
}
if ( tweenArguments.Contains( "a" ) ) {
//colors[1].a=(float)tweenArguments["a"];
for ( int i = 0; i < colors.GetLength( 0 ); i++ ) {
colors[ i, 1 ].a = (float)tweenArguments[ "a" ];
}
}
}
//alpha or amount?
if ( tweenArguments.Contains( "amount" ) ) {
//colors[1].a=(float)tweenArguments["amount"];
for ( int i = 0; i < colors.GetLength( 0 ); i++ ) {
colors[ i, 1 ].a = (float)tweenArguments[ "amount" ];
}
} else if ( tweenArguments.Contains( "alpha" ) ) {
//colors[1].a=(float)tweenArguments["alpha"];
for ( int i = 0; i < colors.GetLength( 0 ); i++ ) {
colors[ i, 1 ].a = (float)tweenArguments[ "alpha" ];
}
}
}
void GenerateAudioToTargets() {
//values holder [0] from, [1] to, [2] calculated value from ease
equation:
vector2s = new Vector2[ 3 ];
//set audioSource:
if ( tweenArguments.Contains( "audiosource" ) ) {
audioSource = (AudioSource)tweenArguments[ "audiosource" ];
} else {
if ( GetComponent<AudioSource>() ) {
audioSource = GetComponent<AudioSource>();
} else {
//throw error if no AudioSource is available:
Debug.LogError( "iTween Error: AudioTo requires an
AudioSource." );
Dispose();
}
}
//to values:
if ( tweenArguments.Contains( "volume" ) ) {
vector2s[ 1 ].x = (float)tweenArguments[ "volume" ];
}
if ( tweenArguments.Contains( "pitch" ) ) {
vector2s[ 1 ].y = (float)tweenArguments[ "pitch" ];
}
}
void GenerateStabTargets() {
//set audioSource:
if ( tweenArguments.Contains( "audiosource" ) ) {
audioSource = (AudioSource)tweenArguments[ "audiosource" ];
} else {
if ( GetComponent<AudioSource>() ) {
audioSource = GetComponent<AudioSource>();
} else {
//add and populate AudioSource if one doesn't exist:
gameObject.AddComponent<AudioSource>();
audioSource = GetComponent<AudioSource>();
audioSource.playOnAwake = false;
}
}
void GenerateLookToTargets() {
//values holder [0] from, [1] to, [2] calculated value from ease
equation:
vector3s = new Vector3[ 3 ];
//from values:
vector3s[ 0 ] = thisTransform.eulerAngles;
//set look:
if ( tweenArguments.Contains( "looktarget" ) ) {
if ( tweenArguments[ "looktarget" ].GetType() ==
typeof( Transform ) ) {
//transform.LookAt((Transform)tweenArguments["looktarget"]);
//to values:
vector3s[ 1 ] = thisTransform.eulerAngles;
thisTransform.eulerAngles = vector3s[ 0 ];
//axis restriction:
if ( tweenArguments.Contains( "axis" ) ) {
switch ( (string)tweenArguments[ "axis" ] ) {
case "x":
vector3s[ 1 ].y = vector3s[ 0 ].y;
vector3s[ 1 ].z = vector3s[ 0 ].z;
break;
case "y":
vector3s[ 1 ].x = vector3s[ 0 ].x;
vector3s[ 1 ].z = vector3s[ 0 ].z;
break;
case "z":
vector3s[ 1 ].x = vector3s[ 0 ].x;
vector3s[ 1 ].y = vector3s[ 0 ].y;
break;
}
}
//shortest distance:
vector3s[ 1 ] = new Vector3( clerp( vector3s[ 0 ].x, vector3s[ 1 ].x, 1
), clerp( vector3s[ 0 ].y, vector3s[ 1 ].y, 1 ), clerp( vector3s[ 0 ].z,
vector3s[ 1 ].z, 1 ) );
void GenerateMoveToPathTargets() {
Vector3[] suppliedPath;
//is this a closed, continuous loop? yes? well then so let's make a
continuous Catmull-Rom spline!
if ( vector3s[ 1 ] == vector3s[ vector3s.Length - 2 ] ) {
Vector3[] tmpLoopSpline = new Vector3[ vector3s.Length ];
Array.Copy( vector3s, tmpLoopSpline, vector3s.Length );
tmpLoopSpline[ 0 ] = tmpLoopSpline[ tmpLoopSpline.Length - 3 ];
tmpLoopSpline[ tmpLoopSpline.Length - 1 ] = tmpLoopSpline[ 2 ];
vector3s = new Vector3[ tmpLoopSpline.Length ];
Array.Copy( tmpLoopSpline, vector3s, tmpLoopSpline.Length );
}
void GenerateMoveToTargets() {
//values holder [0] from, [1] to, [2] calculated value from ease
equation:
vector3s = new Vector3[ 3 ];
//from values:
if ( isLocal ) {
vector3s[ 0 ] = vector3s[ 1 ] = thisTransform.localPosition;
} else {
vector3s[ 0 ] = vector3s[ 1 ] = thisTransform.position;
}
//to values:
if ( tweenArguments.Contains( "position" ) ) {
if ( tweenArguments[ "position" ].GetType() ==
typeof( Transform ) ) {
Transform trans = (Transform)tweenArguments[ "position" ];
vector3s[ 1 ] = trans.position;
} else if ( tweenArguments[ "position" ].GetType() ==
typeof( Vector3 ) ) {
vector3s[ 1 ] = (Vector3)tweenArguments[ "position" ];
}
} else {
if ( tweenArguments.Contains( "x" ) ) {
vector3s[ 1 ].x = (float)tweenArguments[ "x" ];
}
if ( tweenArguments.Contains( "y" ) ) {
vector3s[ 1 ].y = (float)tweenArguments[ "y" ];
}
if ( tweenArguments.Contains( "z" ) ) {
vector3s[ 1 ].z = (float)tweenArguments[ "z" ];
}
}
void GenerateMoveByTargets() {
//values holder [0] from, [1] to, [2] calculated value from ease
equation, [3] previous value for Translate usage to allow Space utilization, [4]
original rotation to make sure look requests don't interfere with the direction
object should move in, [5] for dial in location:
vector3s = new Vector3[ 6 ];
//from values:
vector3s[ 0 ] = vector3s[ 1 ] = vector3s[ 3 ] = thisTransform.position;
//to values:
if ( tweenArguments.Contains( "amount" ) ) {
vector3s[ 1 ] = vector3s[ 0 ] + (Vector3)tweenArguments[ "amount"
];
} else {
if ( tweenArguments.Contains( "x" ) ) {
vector3s[ 1 ].x = vector3s[ 0 ].x +
(float)tweenArguments[ "x" ];
}
if ( tweenArguments.Contains( "y" ) ) {
vector3s[ 1 ].y = vector3s[ 0 ].y +
(float)tweenArguments[ "y" ];
}
if ( tweenArguments.Contains( "z" ) ) {
vector3s[ 1 ].z = vector3s[ 0 ].z +
(float)tweenArguments[ "z" ];
}
}
void GenerateScaleToTargets() {
//values holder [0] from, [1] to, [2] calculated value from ease
equation:
vector3s = new Vector3[ 3 ];
//from values:
vector3s[ 0 ] = vector3s[ 1 ] = thisTransform.localScale;
//to values:
if ( tweenArguments.Contains( "scale" ) ) {
if ( tweenArguments[ "scale" ].GetType() == typeof( Transform ) )
{
Transform trans = (Transform)tweenArguments[ "scale" ];
vector3s[ 1 ] = trans.localScale;
} else if ( tweenArguments[ "scale" ].GetType() ==
typeof( Vector3 ) ) {
vector3s[ 1 ] = (Vector3)tweenArguments[ "scale" ];
}
} else {
if ( tweenArguments.Contains( "x" ) ) {
vector3s[ 1 ].x = (float)tweenArguments[ "x" ];
}
if ( tweenArguments.Contains( "y" ) ) {
vector3s[ 1 ].y = (float)tweenArguments[ "y" ];
}
if ( tweenArguments.Contains( "z" ) ) {
vector3s[ 1 ].z = (float)tweenArguments[ "z" ];
}
}
void GenerateScaleByTargets() {
//values holder [0] from, [1] to, [2] calculated value from ease
equation:
vector3s = new Vector3[ 3 ];
//from values:
vector3s[ 0 ] = vector3s[ 1 ] = thisTransform.localScale;
//to values:
if ( tweenArguments.Contains( "amount" ) ) {
vector3s[ 1 ] = Vector3.Scale( vector3s[ 1 ],
(Vector3)tweenArguments[ "amount" ] );
} else {
if ( tweenArguments.Contains( "x" ) ) {
vector3s[ 1 ].x *= (float)tweenArguments[ "x" ];
}
if ( tweenArguments.Contains( "y" ) ) {
vector3s[ 1 ].y *= (float)tweenArguments[ "y" ];
}
if ( tweenArguments.Contains( "z" ) ) {
vector3s[ 1 ].z *= (float)tweenArguments[ "z" ];
}
}
void GenerateScaleAddTargets() {
//values holder [0] from, [1] to, [2] calculated value from ease
equation:
vector3s = new Vector3[ 3 ];
//from values:
vector3s[ 0 ] = vector3s[ 1 ] = thisTransform.localScale;
//to values:
if ( tweenArguments.Contains( "amount" ) ) {
vector3s[ 1 ] += (Vector3)tweenArguments[ "amount" ];
} else {
if ( tweenArguments.Contains( "x" ) ) {
vector3s[ 1 ].x += (float)tweenArguments[ "x" ];
}
if ( tweenArguments.Contains( "y" ) ) {
vector3s[ 1 ].y += (float)tweenArguments[ "y" ];
}
if ( tweenArguments.Contains( "z" ) ) {
vector3s[ 1 ].z += (float)tweenArguments[ "z" ];
}
}
void GenerateRotateToTargets() {
//values holder [0] from, [1] to, [2] calculated value from ease
equation:
vector3s = new Vector3[ 3 ];
//from values:
if ( isLocal ) {
vector3s[ 0 ] = vector3s[ 1 ] = thisTransform.localEulerAngles;
} else {
vector3s[ 0 ] = vector3s[ 1 ] = thisTransform.eulerAngles;
}
//to values:
if ( tweenArguments.Contains( "rotation" ) ) {
if ( tweenArguments[ "rotation" ].GetType() ==
typeof( Transform ) ) {
Transform trans = (Transform)tweenArguments[ "rotation" ];
vector3s[ 1 ] = trans.eulerAngles;
} else if ( tweenArguments[ "rotation" ].GetType() ==
typeof( Vector3 ) ) {
vector3s[ 1 ] = (Vector3)tweenArguments[ "rotation" ];
}
} else {
if ( tweenArguments.Contains( "x" ) ) {
vector3s[ 1 ].x = (float)tweenArguments[ "x" ];
}
if ( tweenArguments.Contains( "y" ) ) {
vector3s[ 1 ].y = (float)tweenArguments[ "y" ];
}
if ( tweenArguments.Contains( "z" ) ) {
vector3s[ 1 ].z = (float)tweenArguments[ "z" ];
}
}
//shortest distance:
vector3s[ 1 ] = new Vector3( clerp( vector3s[ 0 ].x, vector3s[ 1 ].x, 1
), clerp( vector3s[ 0 ].y, vector3s[ 1 ].y, 1 ), clerp( vector3s[ 0 ].z,
vector3s[ 1 ].z, 1 ) );
void GenerateRotateAddTargets() {
//values holder [0] from, [1] to, [2] calculated value from ease
equation, [3] previous value for Rotate usage to allow Space utilization:
vector3s = new Vector3[ 5 ];
//from values:
vector3s[ 0 ] = vector3s[ 1 ] = vector3s[ 3 ] =
thisTransform.eulerAngles;
//to values:
if ( tweenArguments.Contains( "amount" ) ) {
vector3s[ 1 ] += (Vector3)tweenArguments[ "amount" ];
} else {
if ( tweenArguments.Contains( "x" ) ) {
vector3s[ 1 ].x += (float)tweenArguments[ "x" ];
}
if ( tweenArguments.Contains( "y" ) ) {
vector3s[ 1 ].y += (float)tweenArguments[ "y" ];
}
if ( tweenArguments.Contains( "z" ) ) {
vector3s[ 1 ].z += (float)tweenArguments[ "z" ];
}
}
void GenerateRotateByTargets() {
//values holder [0] from, [1] to, [2] calculated value from ease
equation, [3] previous value for Rotate usage to allow Space utilization:
vector3s = new Vector3[ 4 ];
//from values:
vector3s[ 0 ] = vector3s[ 1 ] = vector3s[ 3 ] =
thisTransform.eulerAngles;
//to values:
if ( tweenArguments.Contains( "amount" ) ) {
vector3s[ 1 ] += Vector3.Scale( (Vector3)tweenArguments[ "amount"
], new Vector3( 360, 360, 360 ) );
} else {
if ( tweenArguments.Contains( "x" ) ) {
vector3s[ 1 ].x += 360 * (float)tweenArguments[ "x" ];
}
if ( tweenArguments.Contains( "y" ) ) {
vector3s[ 1 ].y += 360 * (float)tweenArguments[ "y" ];
}
if ( tweenArguments.Contains( "z" ) ) {
vector3s[ 1 ].z += 360 * (float)tweenArguments[ "z" ];
}
}
void GenerateShakePositionTargets() {
//values holder [0] from, [1] to, [2] calculated value from ease
equation, [3] original rotation to make sure look requests don't interfere with the
direction object should move in:
vector3s = new Vector3[ 4 ];
//root:
vector3s[ 0 ] = thisTransform.position;
//amount:
if ( tweenArguments.Contains( "amount" ) ) {
vector3s[ 1 ] = (Vector3)tweenArguments[ "amount" ];
} else {
if ( tweenArguments.Contains( "x" ) ) {
vector3s[ 1 ].x = (float)tweenArguments[ "x" ];
}
if ( tweenArguments.Contains( "y" ) ) {
vector3s[ 1 ].y = (float)tweenArguments[ "y" ];
}
if ( tweenArguments.Contains( "z" ) ) {
vector3s[ 1 ].z = (float)tweenArguments[ "z" ];
}
}
}
void GenerateShakeScaleTargets() {
//values holder [0] root value, [1] amount, [2] generated amount:
vector3s = new Vector3[ 3 ];
//root:
vector3s[ 0 ] = thisTransform.localScale;
//amount:
if ( tweenArguments.Contains( "amount" ) ) {
vector3s[ 1 ] = (Vector3)tweenArguments[ "amount" ];
} else {
if ( tweenArguments.Contains( "x" ) ) {
vector3s[ 1 ].x = (float)tweenArguments[ "x" ];
}
if ( tweenArguments.Contains( "y" ) ) {
vector3s[ 1 ].y = (float)tweenArguments[ "y" ];
}
if ( tweenArguments.Contains( "z" ) ) {
vector3s[ 1 ].z = (float)tweenArguments[ "z" ];
}
}
}
void GenerateShakeRotationTargets() {
//values holder [0] root value, [1] amount, [2] generated amount:
vector3s = new Vector3[ 3 ];
//root:
vector3s[ 0 ] = thisTransform.eulerAngles;
//amount:
if ( tweenArguments.Contains( "amount" ) ) {
vector3s[ 1 ] = (Vector3)tweenArguments[ "amount" ];
} else {
if ( tweenArguments.Contains( "x" ) ) {
vector3s[ 1 ].x = (float)tweenArguments[ "x" ];
}
if ( tweenArguments.Contains( "y" ) ) {
vector3s[ 1 ].y = (float)tweenArguments[ "y" ];
}
if ( tweenArguments.Contains( "z" ) ) {
vector3s[ 1 ].z = (float)tweenArguments[ "z" ];
}
}
}
void GeneratePunchPositionTargets() {
//values holder [0] from, [1] to, [2] calculated value from ease
equation, [3] previous value for Translate usage to allow Space utilization, [4]
original rotation to make sure look requests don't interfere with the direction
object should move in:
vector3s = new Vector3[ 5 ];
//from values:
vector3s[ 0 ] = thisTransform.position;
vector3s[ 1 ] = vector3s[ 3 ] = Vector3.zero;
//to values:
if ( tweenArguments.Contains( "amount" ) ) {
vector3s[ 1 ] = (Vector3)tweenArguments[ "amount" ];
} else {
if ( tweenArguments.Contains( "x" ) ) {
vector3s[ 1 ].x = (float)tweenArguments[ "x" ];
}
if ( tweenArguments.Contains( "y" ) ) {
vector3s[ 1 ].y = (float)tweenArguments[ "y" ];
}
if ( tweenArguments.Contains( "z" ) ) {
vector3s[ 1 ].z = (float)tweenArguments[ "z" ];
}
}
}
void GeneratePunchRotationTargets() {
//values holder [0] from, [1] to, [2] calculated value from ease
equation, [3] previous value for Translate usage to allow Space utilization:
vector3s = new Vector3[ 4 ];
//from values:
vector3s[ 0 ] = thisTransform.eulerAngles;
vector3s[ 1 ] = vector3s[ 3 ] = Vector3.zero;
//to values:
if ( tweenArguments.Contains( "amount" ) ) {
vector3s[ 1 ] = (Vector3)tweenArguments[ "amount" ];
} else {
if ( tweenArguments.Contains( "x" ) ) {
vector3s[ 1 ].x = (float)tweenArguments[ "x" ];
}
if ( tweenArguments.Contains( "y" ) ) {
vector3s[ 1 ].y = (float)tweenArguments[ "y" ];
}
if ( tweenArguments.Contains( "z" ) ) {
vector3s[ 1 ].z = (float)tweenArguments[ "z" ];
}
}
}
void GeneratePunchScaleTargets() {
//values holder [0] from, [1] to, [2] calculated value from ease
equation:
vector3s = new Vector3[ 3 ];
//from values:
vector3s[ 0 ] = thisTransform.localScale;
vector3s[ 1 ] = Vector3.zero;
//to values:
if ( tweenArguments.Contains( "amount" ) ) {
vector3s[ 1 ] = (Vector3)tweenArguments[ "amount" ];
} else {
if ( tweenArguments.Contains( "x" ) ) {
vector3s[ 1 ].x = (float)tweenArguments[ "x" ];
}
if ( tweenArguments.Contains( "y" ) ) {
vector3s[ 1 ].y = (float)tweenArguments[ "y" ];
}
if ( tweenArguments.Contains( "z" ) ) {
vector3s[ 1 ].z = (float)tweenArguments[ "z" ];
}
}
}
#endregion
void ApplyRectTargets() {
//calculate:
rects[ 2 ].x = ease( rects[ 0 ].x, rects[ 1 ].x, percentage );
rects[ 2 ].y = ease( rects[ 0 ].y, rects[ 1 ].y, percentage );
rects[ 2 ].width = ease( rects[ 0 ].width, rects[ 1 ].width, percentage
);
rects[ 2 ].height = ease( rects[ 0 ].height, rects[ 1 ].height,
percentage );
//apply:
tweenArguments[ "onupdateparams" ] = rects[ 2 ];
//dial in:
if ( percentage == 1 ) {
tweenArguments[ "onupdateparams" ] = rects[ 1 ];
}
}
void ApplyColorTargets() {
//calculate:
colors[ 0, 2 ].r = ease( colors[ 0, 0 ].r, colors[ 0, 1 ].r, percentage
);
colors[ 0, 2 ].g = ease( colors[ 0, 0 ].g, colors[ 0, 1 ].g, percentage
);
colors[ 0, 2 ].b = ease( colors[ 0, 0 ].b, colors[ 0, 1 ].b, percentage
);
colors[ 0, 2 ].a = ease( colors[ 0, 0 ].a, colors[ 0, 1 ].a, percentage
);
//apply:
tweenArguments[ "onupdateparams" ] = colors[ 0, 2 ];
//dial in:
if ( percentage == 1 ) {
tweenArguments[ "onupdateparams" ] = colors[ 0, 1 ];
}
}
void ApplyVector3Targets() {
//calculate:
vector3s[ 2 ].x = ease( vector3s[ 0 ].x, vector3s[ 1 ].x, percentage );
vector3s[ 2 ].y = ease( vector3s[ 0 ].y, vector3s[ 1 ].y, percentage );
vector3s[ 2 ].z = ease( vector3s[ 0 ].z, vector3s[ 1 ].z, percentage );
//apply:
tweenArguments[ "onupdateparams" ] = vector3s[ 2 ];
//dial in:
if ( percentage == 1 ) {
tweenArguments[ "onupdateparams" ] = vector3s[ 1 ];
}
}
void ApplyVector2Targets() {
//calculate:
vector2s[ 2 ].x = ease( vector2s[ 0 ].x, vector2s[ 1 ].x, percentage );
vector2s[ 2 ].y = ease( vector2s[ 0 ].y, vector2s[ 1 ].y, percentage );
//apply:
tweenArguments[ "onupdateparams" ] = vector2s[ 2 ];
//dial in:
if ( percentage == 1 ) {
tweenArguments[ "onupdateparams" ] = vector2s[ 1 ];
}
}
void ApplyFloatTargets() {
//calculate:
floats[ 2 ] = ease( floats[ 0 ], floats[ 1 ], percentage );
//apply:
tweenArguments[ "onupdateparams" ] = floats[ 2 ];
//dial in:
if ( percentage == 1 ) {
tweenArguments[ "onupdateparams" ] = floats[ 1 ];
}
}
void ApplyColorToTargets() {
//calculate:
for ( int i = 0; i < colors.GetLength( 0 ); i++ ) {
colors[ i, 2 ].r = ease( colors[ i, 0 ].r, colors[ i, 1 ].r,
percentage );
colors[ i, 2 ].g = ease( colors[ i, 0 ].g, colors[ i, 1 ].g,
percentage );
colors[ i, 2 ].b = ease( colors[ i, 0 ].b, colors[ i, 1 ].b,
percentage );
colors[ i, 2 ].a = ease( colors[ i, 0 ].a, colors[ i, 1 ].a,
percentage );
}
/*
colors[2].r = ease(colors[0].r,colors[1].r,percentage);
colors[2].g = ease(colors[0].g,colors[1].g,percentage);
colors[2].b = ease(colors[0].b,colors[1].b,percentage);
colors[2].a = ease(colors[0].a,colors[1].a,percentage);
*/
//apply:
if ( GetComponent<Image>() ) {
//guiTexture.color=colors[2];
GetComponent<Image>().color = colors[ 0, 2 ];
} else if ( GetComponent<Text>() ) {
//guiText.material.color=colors[2];
GetComponent<Text>().material.color = colors[ 0, 2 ];
} else if ( GetComponent<Renderer>() ) {
//renderer.material.color=colors[2];
for ( int i = 0; i < colors.GetLength( 0 ); i++ ) {
//dial in:
if ( percentage == 1 ) {
if ( GetComponent<Image>() ) {
//guiTexture.color=colors[1];
GetComponent<Image>().color = colors[ 0, 1 ];
} else if ( GetComponent<Text>() ) {
//guiText.material.color=colors[1];
GetComponent<Text>().material.color = colors[ 0, 1 ];
} else if ( GetComponent<Renderer>() ) {
//renderer.material.color=colors[1];
for ( int i = 0; i < colors.GetLength( 0 ); i++ ) {
void ApplyAudioToTargets() {
//calculate:
vector2s[ 2 ].x = ease( vector2s[ 0 ].x, vector2s[ 1 ].x, percentage );
vector2s[ 2 ].y = ease( vector2s[ 0 ].y, vector2s[ 1 ].y, percentage );
//apply:
audioSource.volume = vector2s[ 2 ].x;
audioSource.pitch = vector2s[ 2 ].y;
//dial in:
if ( percentage == 1 ) {
audioSource.volume = vector2s[ 1 ].x;
audioSource.pitch = vector2s[ 1 ].y;
}
}
void ApplyStabTargets() {
//unnecessary but here just in case
}
void ApplyMoveToPathTargets() {
preUpdate = thisTransform.position;
float t = ease( 0, 1, percentage );
float lookAheadAmount;
//need physics?
postUpdate = thisTransform.position;
if ( physics ) {
thisTransform.position = preUpdate;
GetComponent<Rigidbody>().MovePosition( postUpdate );
}
}
void ApplyMoveToTargets() {
//record current:
preUpdate = thisTransform.position;
//calculate:
vector3s[ 2 ].x = ease( vector3s[ 0 ].x, vector3s[ 1 ].x, percentage );
vector3s[ 2 ].y = ease( vector3s[ 0 ].y, vector3s[ 1 ].y, percentage );
vector3s[ 2 ].z = ease( vector3s[ 0 ].z, vector3s[ 1 ].z, percentage );
//apply:
if ( isLocal ) {
thisTransform.localPosition = vector3s[ 2 ];
} else {
thisTransform.position = vector3s[ 2 ];
}
//dial in:
if ( percentage == 1 ) {
if ( isLocal ) {
thisTransform.localPosition = vector3s[ 1 ];
} else {
thisTransform.position = vector3s[ 1 ];
}
}
//need physics?
postUpdate = thisTransform.position;
if ( physics ) {
thisTransform.position = preUpdate;
GetComponent<Rigidbody>().MovePosition( postUpdate );
}
}
void ApplyMoveByTargets() {
preUpdate = thisTransform.position;
if ( tweenArguments.Contains( "looktarget" ) ) {
currentRotation = thisTransform.eulerAngles;
thisTransform.eulerAngles = vector3s[ 4 ];
}
//calculate:
vector3s[ 2 ].x = ease( vector3s[ 0 ].x, vector3s[ 1 ].x, percentage );
vector3s[ 2 ].y = ease( vector3s[ 0 ].y, vector3s[ 1 ].y, percentage );
vector3s[ 2 ].z = ease( vector3s[ 0 ].z, vector3s[ 1 ].z, percentage );
//apply:
thisTransform.Translate( vector3s[ 2 ] - vector3s[ 3 ], space );
//record:
vector3s[ 3 ] = vector3s[ 2 ];
//reset rotation:
if ( tweenArguments.Contains( "looktarget" ) ) {
thisTransform.eulerAngles = currentRotation;
}
/*
//dial in:
if(percentage==1){
transform.position=vector3s[5];
}
*/
//need physics?
postUpdate = thisTransform.position;
if ( physics ) {
thisTransform.position = preUpdate;
GetComponent<Rigidbody>().MovePosition( postUpdate );
}
}
void ApplyScaleToTargets() {
//calculate:
vector3s[ 2 ].x = ease( vector3s[ 0 ].x, vector3s[ 1 ].x, percentage );
vector3s[ 2 ].y = ease( vector3s[ 0 ].y, vector3s[ 1 ].y, percentage );
vector3s[ 2 ].z = ease( vector3s[ 0 ].z, vector3s[ 1 ].z, percentage );
//apply:
thisTransform.localScale = vector3s[ 2 ];
//dial in:
if ( percentage == 1 ) {
thisTransform.localScale = vector3s[ 1 ];
}
}
void ApplyLookToTargets() {
//calculate:
vector3s[ 2 ].x = ease( vector3s[ 0 ].x, vector3s[ 1 ].x, percentage );
vector3s[ 2 ].y = ease( vector3s[ 0 ].y, vector3s[ 1 ].y, percentage );
vector3s[ 2 ].z = ease( vector3s[ 0 ].z, vector3s[ 1 ].z, percentage );
//apply:
if ( isLocal ) {
thisTransform.localRotation = Quaternion.Euler( vector3s[ 2 ] );
} else {
thisTransform.rotation = Quaternion.Euler( vector3s[ 2 ] );
};
}
void ApplyRotateToTargets() {
preUpdate = thisTransform.eulerAngles;
//calculate:
vector3s[ 2 ].x = ease( vector3s[ 0 ].x, vector3s[ 1 ].x, percentage );
vector3s[ 2 ].y = ease( vector3s[ 0 ].y, vector3s[ 1 ].y, percentage );
vector3s[ 2 ].z = ease( vector3s[ 0 ].z, vector3s[ 1 ].z, percentage );
//apply:
if ( isLocal ) {
thisTransform.localRotation = Quaternion.Euler( vector3s[ 2 ] );
} else {
thisTransform.rotation = Quaternion.Euler( vector3s[ 2 ] );
};
//dial in:
if ( percentage == 1 ) {
if ( isLocal ) {
thisTransform.localRotation = Quaternion.Euler( vector3s[ 1
] );
} else {
thisTransform.rotation = Quaternion.Euler( vector3s[ 1 ] );
};
}
//need physics?
postUpdate = thisTransform.eulerAngles;
if ( physics ) {
thisTransform.eulerAngles = preUpdate;
void ApplyRotateAddTargets() {
preUpdate = thisTransform.eulerAngles;
//calculate:
vector3s[ 2 ].x = ease( vector3s[ 0 ].x, vector3s[ 1 ].x, percentage );
vector3s[ 2 ].y = ease( vector3s[ 0 ].y, vector3s[ 1 ].y, percentage );
vector3s[ 2 ].z = ease( vector3s[ 0 ].z, vector3s[ 1 ].z, percentage );
//apply:
thisTransform.Rotate( vector3s[ 2 ] - vector3s[ 3 ], space );
//record:
vector3s[ 3 ] = vector3s[ 2 ];
//need physics?
postUpdate = thisTransform.eulerAngles;
if ( physics ) {
thisTransform.eulerAngles = preUpdate;
void ApplyShakePositionTargets() {
//preUpdate = transform.position;
if ( isLocal ) {
preUpdate = thisTransform.localPosition;
} else {
preUpdate = thisTransform.position;
}
if ( tweenArguments.Contains( "looktarget" ) ) {
currentRotation = thisTransform.eulerAngles;
thisTransform.eulerAngles = vector3s[ 3 ];
}
//impact:
if ( percentage == 0 ) {
thisTransform.Translate( vector3s[ 1 ], space );
}
//transform.position=vector3s[0];
//reset:
if ( isLocal ) {
thisTransform.localPosition = vector3s[ 0 ];
} else {
thisTransform.position = vector3s[ 0 ];
}
//generate:
float diminishingControl = 1 - percentage;
vector3s[ 2 ].x = UnityEngine.Random.Range( -vector3s[ 1 ].x *
diminishingControl, vector3s[ 1 ].x * diminishingControl );
vector3s[ 2 ].y = UnityEngine.Random.Range( -vector3s[ 1 ].y *
diminishingControl, vector3s[ 1 ].y * diminishingControl );
vector3s[ 2 ].z = UnityEngine.Random.Range( -vector3s[ 1 ].z *
diminishingControl, vector3s[ 1 ].z * diminishingControl );
//apply:
//transform.Translate(vector3s[2],space);
if ( isLocal ) {
thisTransform.localPosition += vector3s[ 2 ];
} else {
thisTransform.position += vector3s[ 2 ];
}
//reset rotation:
if ( tweenArguments.Contains( "looktarget" ) ) {
thisTransform.eulerAngles = currentRotation;
}
//need physics?
postUpdate = thisTransform.position;
if ( physics ) {
thisTransform.position = preUpdate;
GetComponent<Rigidbody>().MovePosition( postUpdate );
}
}
void ApplyShakeScaleTargets() {
//impact:
if ( percentage == 0 ) {
thisTransform.localScale = vector3s[ 1 ];
}
//reset:
thisTransform.localScale = vector3s[ 0 ];
//generate:
float diminishingControl = 1 - percentage;
vector3s[ 2 ].x = UnityEngine.Random.Range( -vector3s[ 1 ].x *
diminishingControl, vector3s[ 1 ].x * diminishingControl );
vector3s[ 2 ].y = UnityEngine.Random.Range( -vector3s[ 1 ].y *
diminishingControl, vector3s[ 1 ].y * diminishingControl );
vector3s[ 2 ].z = UnityEngine.Random.Range( -vector3s[ 1 ].z *
diminishingControl, vector3s[ 1 ].z * diminishingControl );
//apply:
thisTransform.localScale += vector3s[ 2 ];
}
void ApplyShakeRotationTargets() {
preUpdate = thisTransform.eulerAngles;
//impact:
if ( percentage == 0 ) {
thisTransform.Rotate( vector3s[ 1 ], space );
}
//reset:
thisTransform.eulerAngles = vector3s[ 0 ];
//generate:
float diminishingControl = 1 - percentage;
vector3s[ 2 ].x = UnityEngine.Random.Range( -vector3s[ 1 ].x *
diminishingControl, vector3s[ 1 ].x * diminishingControl );
vector3s[ 2 ].y = UnityEngine.Random.Range( -vector3s[ 1 ].y *
diminishingControl, vector3s[ 1 ].y * diminishingControl );
vector3s[ 2 ].z = UnityEngine.Random.Range( -vector3s[ 1 ].z *
diminishingControl, vector3s[ 1 ].z * diminishingControl );
//apply:
thisTransform.Rotate( vector3s[ 2 ], space );
//need physics?
postUpdate = thisTransform.eulerAngles;
if ( physics ) {
thisTransform.eulerAngles = preUpdate;
void ApplyPunchPositionTargets() {
preUpdate = thisTransform.position;
if ( tweenArguments.Contains( "looktarget" ) ) {
currentRotation = thisTransform.eulerAngles;
thisTransform.eulerAngles = vector3s[ 4 ];
}
//calculate:
if ( vector3s[ 1 ].x > 0 ) {
vector3s[ 2 ].x = punch( vector3s[ 1 ].x, percentage );
} else if ( vector3s[ 1 ].x < 0 ) {
vector3s[ 2 ].x = -punch( Mathf.Abs( vector3s[ 1 ].x ),
percentage );
}
if ( vector3s[ 1 ].y > 0 ) {
vector3s[ 2 ].y = punch( vector3s[ 1 ].y, percentage );
} else if ( vector3s[ 1 ].y < 0 ) {
vector3s[ 2 ].y = -punch( Mathf.Abs( vector3s[ 1 ].y ),
percentage );
}
if ( vector3s[ 1 ].z > 0 ) {
vector3s[ 2 ].z = punch( vector3s[ 1 ].z, percentage );
} else if ( vector3s[ 1 ].z < 0 ) {
vector3s[ 2 ].z = -punch( Mathf.Abs( vector3s[ 1 ].z ),
percentage );
}
//apply:
thisTransform.Translate( vector3s[ 2 ] - vector3s[ 3 ], space );
//record:
vector3s[ 3 ] = vector3s[ 2 ];
//reset rotation:
if ( tweenArguments.Contains( "looktarget" ) ) {
thisTransform.eulerAngles = currentRotation;
}
//dial in:
/*
if(percentage==1){
transform.position=vector3s[0];
}
*/
//need physics?
postUpdate = thisTransform.position;
if ( physics ) {
thisTransform.position = preUpdate;
GetComponent<Rigidbody>().MovePosition( postUpdate );
}
}
void ApplyPunchRotationTargets() {
preUpdate = thisTransform.eulerAngles;
//calculate:
if ( vector3s[ 1 ].x > 0 ) {
vector3s[ 2 ].x = punch( vector3s[ 1 ].x, percentage );
} else if ( vector3s[ 1 ].x < 0 ) {
vector3s[ 2 ].x = -punch( Mathf.Abs( vector3s[ 1 ].x ),
percentage );
}
if ( vector3s[ 1 ].y > 0 ) {
vector3s[ 2 ].y = punch( vector3s[ 1 ].y, percentage );
} else if ( vector3s[ 1 ].y < 0 ) {
vector3s[ 2 ].y = -punch( Mathf.Abs( vector3s[ 1 ].y ),
percentage );
}
if ( vector3s[ 1 ].z > 0 ) {
vector3s[ 2 ].z = punch( vector3s[ 1 ].z, percentage );
} else if ( vector3s[ 1 ].z < 0 ) {
vector3s[ 2 ].z = -punch( Mathf.Abs( vector3s[ 1 ].z ),
percentage );
}
//apply:
thisTransform.Rotate( vector3s[ 2 ] - vector3s[ 3 ], space );
//record:
vector3s[ 3 ] = vector3s[ 2 ];
//dial in:
/*
if(percentage==1){
transform.eulerAngles=vector3s[0];
}
*/
//need physics?
postUpdate = thisTransform.eulerAngles;
if ( physics ) {
thisTransform.eulerAngles = preUpdate;
void ApplyPunchScaleTargets() {
//calculate:
if ( vector3s[ 1 ].x > 0 ) {
vector3s[ 2 ].x = punch( vector3s[ 1 ].x, percentage );
} else if ( vector3s[ 1 ].x < 0 ) {
vector3s[ 2 ].x = -punch( Mathf.Abs( vector3s[ 1 ].x ),
percentage );
}
if ( vector3s[ 1 ].y > 0 ) {
vector3s[ 2 ].y = punch( vector3s[ 1 ].y, percentage );
} else if ( vector3s[ 1 ].y < 0 ) {
vector3s[ 2 ].y = -punch( Mathf.Abs( vector3s[ 1 ].y ),
percentage );
}
if ( vector3s[ 1 ].z > 0 ) {
vector3s[ 2 ].z = punch( vector3s[ 1 ].z, percentage );
} else if ( vector3s[ 1 ].z < 0 ) {
vector3s[ 2 ].z = -punch( Mathf.Abs( vector3s[ 1 ].z ),
percentage );
}
//apply:
thisTransform.localScale = vector3s[ 0 ] + vector3s[ 2 ];
//dial in:
/*
if(percentage==1){
transform.localScale=vector3s[0];
}
*/
}
#endregion
void TweenStart() {
CallBack( "onstart" );
//run stab:
if ( type == "stab" ) {
audioSource.PlayOneShot( audioSource.clip );
}
isRunning = true;
}
IEnumerator TweenRestart() {
if ( delay > 0 ) {
delayStarted = Time.time;
yield return new WaitForSeconds( delay );
}
loop = true;
TweenStart();
}
void TweenUpdate() {
apply();
CallBack( "onupdate" );
UpdatePercentage();
}
void TweenComplete() {
isRunning = false;
//loop or dispose?
if ( loopType == LoopType.none ) {
Dispose();
} else {
TweenLoop();
}
CallBack( "oncomplete" );
}
void TweenLoop() {
DisableKinematic(); //give physics control again
switch ( loopType ) {
case LoopType.loop:
//rewind:
percentage = 0;
runningTime = 0;
apply();
//replay:
StartCoroutine( "TweenRestart" );
break;
case LoopType.pingPong:
reverse = !reverse;
runningTime = 0;
//replay:
StartCoroutine( "TweenRestart" );
break;
}
}
#endregion
/// <summary>
/// Returns a Rect that is eased between a current and target value by the
supplied speed.
/// </summary>
/// <returns>
/// A <see cref="Rect"/
/// </returns>
/// <param name='currentValue'>
/// A <see cref="Rect"/> the starting or initial value
/// </param>
/// <param name='targetValue'>
/// A <see cref="Rect"/> the target value that the current value will be
eased to.
/// </param>
/// <param name='speed'>
/// A <see cref="System.Single"/> to be used as rate of speed (larger number
equals faster animation)
/// </param>
public static Rect RectUpdate( Rect currentValue, Rect targetValue, float
speed ) {
Rect diff = new Rect( FloatUpdate( currentValue.x, targetValue.x, speed
), FloatUpdate( currentValue.y, targetValue.y, speed ),
FloatUpdate( currentValue.width, targetValue.width, speed ),
FloatUpdate( currentValue.height, targetValue.height, speed ) );
return ( diff );
}
/// <summary>
/// Returns a Vector3 that is eased between a current and target value by the
supplied speed.
/// </summary>
/// <returns>
/// A <see cref="Vector3"/>
/// </returns>
/// <param name='currentValue'>
/// A <see cref="Vector3"/> the starting or initial value
/// </param>
/// <param name='targetValue'>
/// A <see cref="Vector3"/> the target value that the current value will be
eased to.
/// </param>
/// <param name='speed'>
/// A <see cref="System.Single"/> to be used as rate of speed (larger number
equals faster animation)
/// </param>
public static Vector3 Vector3Update( Vector3 currentValue, Vector3
targetValue, float speed ) {
Vector3 diff = targetValue - currentValue;
currentValue += ( diff * speed ) * Time.deltaTime;
return ( currentValue );
}
/// <summary>
/// Returns a Vector2 that is eased between a current and target value by the
supplied speed.
/// </summary>
/// <returns>
/// A <see cref="Vector2"/>
/// </returns>
/// <param name='currentValue'>
/// A <see cref="Vector2"/> the starting or initial value
/// </param>
/// <param name='targetValue'>
/// A <see cref="Vector2"/> the target value that the current value will be
eased to.
/// </param>
/// <param name='speed'>
/// A <see cref="System.Single"/> to be used as rate of speed (larger number
equals faster animation)
/// </param>
public static Vector2 Vector2Update( Vector2 currentValue, Vector2
targetValue, float speed ) {
Vector2 diff = targetValue - currentValue;
currentValue += ( diff * speed ) * Time.deltaTime;
return ( currentValue );
}
/// <summary>
/// Returns a float that is eased between a current and target value by the
supplied speed.
/// </summary>
/// <returns>
/// A <see cref="System.Single"/>
/// </returns>
/// <param name='currentValue'>
/// A <see cref="System.Single"/> the starting or initial value
/// </param>
/// <param name='targetValue'>
/// A <see cref="System.Single"/> the target value that the current value
will be eased to.
/// </param>
/// <param name='speed'>
/// A <see cref="System.Single"/> to be used as rate of speed (larger number
equals faster animation)
/// </param>
public static float FloatUpdate( float currentValue, float targetValue, float
speed ) {
float diff = targetValue - currentValue;
currentValue += ( diff * speed ) * Time.deltaTime;
return ( currentValue );
}
/// <summary>
/// Similar to FadeTo but incredibly less expensive for usage inside the
Update function or similar looping situations involving a "live" set of changing
values with FULL customization options. Does not utilize an EaseType.
/// </summary>
/// <param name="alpha">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
final alpha value of the animation.
/// </param>
/// <param name="includechildren">
/// A <see cref="System.Boolean"/> for whether or not to include children of
this GameObject. True by default.
/// </param>
/// <param name="time">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time
in seconds the animation will take to complete.
/// </param>
public static void FadeUpdate( GameObject target, Hashtable args ) {
args[ "a" ] = args[ "alpha" ];
ColorUpdate( target, args );
}
/// <summary>
/// Similar to FadeTo but incredibly less expensive for usage inside the
Update function or similar looping situations involving a "live" set of changing
values with MINIMUM customization options. Does not utilize an EaseType.
/// </summary>
/// <param name="target">
/// A <see cref="GameObject"/> to be the target of the animation.
/// </param>
/// <param name="alpha">
/// A <see cref="System.Single"/> for the final alpha value of the animation.
/// </param>
/// <param name="time">
/// A <see cref="System.Single"/> for the time in seconds the animation will
take to complete.
/// </param>
public static void FadeUpdate( GameObject target, float alpha, float time ) {
FadeUpdate( target, Hash( "alpha", alpha, "time", time ) );
}
/// <summary>
/// Similar to ColorTo but incredibly less expensive for usage inside the
Update function or similar looping situations involving a "live" set of changing
values with FULL customization options. Does not utilize an EaseType.
/// </summary>
/// <param name="color">
/// A <see cref="Color"/> to change the GameObject's color to.
/// </param>
/// <param name="r">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
individual setting of the color red.
/// </param>
/// <param name="g">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
individual setting of the color green.
/// </param>
/// <param name="b">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
individual setting of the color green.
/// </param>
/// <param name="a">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
individual setting of the alpha.
/// </param>
/// <param name="namedcolorvalue">
/// A <see cref="NamedColorValue"/> or <see cref="System.String"/> for the
individual setting of the alpha.
/// </param>
/// <param name="includechildren">
/// A <see cref="System.Boolean"/> for whether or not to include children of
this GameObject. True by default.
/// </param>
/// <param name="time">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time
in seconds the animation will take to complete.
/// </param>
public static void ColorUpdate( GameObject target, Hashtable args ) {
CleanArgs( args );
float time;
Color[] colors = new Color[ 4 ];
//handle children:
if ( !args.Contains( "includechildren" ) ||
(bool)args[ "includechildren" ] ) {
foreach ( Transform child in target.transform ) {
ColorUpdate( child.gameObject, args );
}
}
//init values:
if ( target.GetComponent<Image>() ) {
colors[ 0 ] = colors[ 1 ] = target.GetComponent<Image>().color;
} else if ( target.GetComponent<Text>() ) {
colors[ 0 ] = colors[ 1 ] =
target.GetComponent<Text>().material.color;
} else if ( target.GetComponent<Renderer>() ) {
colors[ 0 ] = colors[ 1 ] =
target.GetComponent<Renderer>().material.color;
} else if ( target.GetComponent<Light>() ) {
colors[ 0 ] = colors[ 1 ] = target.GetComponent<Light>().color;
}
//to values:
if ( args.Contains( "color" ) ) {
colors[ 1 ] = (Color)args[ "color" ];
} else {
if ( args.Contains( "r" ) ) {
colors[ 1 ].r = (float)args[ "r" ];
}
if ( args.Contains( "g" ) ) {
colors[ 1 ].g = (float)args[ "g" ];
}
if ( args.Contains( "b" ) ) {
colors[ 1 ].b = (float)args[ "b" ];
}
if ( args.Contains( "a" ) ) {
colors[ 1 ].a = (float)args[ "a" ];
}
}
//calculate:
colors[ 3 ].r = Mathf.SmoothDamp( colors[ 0 ].r, colors[ 1 ].r, ref
colors[ 2 ].r, time );
colors[ 3 ].g = Mathf.SmoothDamp( colors[ 0 ].g, colors[ 1 ].g, ref
colors[ 2 ].g, time );
colors[ 3 ].b = Mathf.SmoothDamp( colors[ 0 ].b, colors[ 1 ].b, ref
colors[ 2 ].b, time );
colors[ 3 ].a = Mathf.SmoothDamp( colors[ 0 ].a, colors[ 1 ].a, ref
colors[ 2 ].a, time );
//apply:
if ( target.GetComponent<Image>() ) {
target.GetComponent<Image>().color = colors[ 3 ];
} else if ( target.GetComponent<Text>() ) {
target.GetComponent<Text>().material.color = colors[ 3 ];
} else if ( target.GetComponent<Renderer>() ) {
target.GetComponent<Renderer>().material.color = colors[ 3 ];
} else if ( target.GetComponent<Light>() ) {
target.GetComponent<Light>().color = colors[ 3 ];
}
}
/// <summary>
/// Similar to ColorTo but incredibly less expensive for usage inside the
Update function or similar looping situations involving a "live" set of changing
values with MINIMUM customization options. Does not utilize an EaseType.
/// </summary>
/// <param name="target">
/// A <see cref="GameObject"/> to be the target of the animation.
/// </param>
/// <param name="color">
/// A <see cref="Color"/> to change the GameObject's color to.
/// </param>
/// <param name="time">
/// A <see cref="System.Single"/> for the time in seconds the animation will
take to complete.
/// </param>
public static void ColorUpdate( GameObject target, Color color, float time )
{
ColorUpdate( target, Hash( "color", color, "time", time ) );
}
/// <summary>
/// Similar to AudioTo but incredibly less expensive for usage inside the
Update function or similar looping situations involving a "live" set of changing
values with FULL customization options. Does not utilize an EaseType.
/// </summary>
/// <param name="audiosource">
/// A <see cref="AudioSource"/> for which AudioSource to use.
/// </param>
/// <param name="volume">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
target level of volume.
/// </param>
/// <param name="pitch">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
target pitch.
/// </param>
/// <param name="time">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time
in seconds the animation will take to complete.
/// </param>
public static void AudioUpdate( GameObject target, Hashtable args ) {
CleanArgs( args );
AudioSource audioSource;
float time;
Vector2[] vector2s = new Vector2[ 4 ];
//set audioSource:
if ( args.Contains( "audiosource" ) ) {
audioSource = (AudioSource)args[ "audiosource" ];
} else {
if ( target.GetComponent<AudioSource>() ) {
audioSource = target.GetComponent<AudioSource>();
} else {
//throw error if no AudioSource is available:
Debug.LogError( "iTween Error: AudioUpdate requires an
AudioSource." );
return;
}
}
//from values:
vector2s[ 0 ] = vector2s[ 1 ] = new Vector2( audioSource.volume,
audioSource.pitch );
//set to:
if ( args.Contains( "volume" ) ) {
vector2s[ 1 ].x = (float)args[ "volume" ];
}
if ( args.Contains( "pitch" ) ) {
vector2s[ 1 ].y = (float)args[ "pitch" ];
}
//calculate:
vector2s[ 3 ].x = Mathf.SmoothDampAngle( vector2s[ 0 ].x,
vector2s[ 1 ].x, ref vector2s[ 2 ].x, time );
vector2s[ 3 ].y = Mathf.SmoothDampAngle( vector2s[ 0 ].y,
vector2s[ 1 ].y, ref vector2s[ 2 ].y, time );
//apply:
audioSource.volume = vector2s[ 3 ].x;
audioSource.pitch = vector2s[ 3 ].y;
}
/// <summary>
/// Similar to AudioTo but incredibly less expensive for usage inside the
Update function or similar looping situations involving a "live" set of changing
values with MINIMUM customization options. Does not utilize an EaseType.
/// </summary>
/// <param name="target">
/// A <see cref="GameObject"/> to be the target of the animation.
/// </param>
/// <param name="volume">
/// A <see cref="System.Single"/> for the target level of volume.
/// </param>
/// <param name="pitch">
/// A <see cref="System.Single"/> for the target pitch.
/// </param>
/// <param name="time">
/// A <see cref="System.Single"/> for the time in seconds the animation will
take to complete.
/// </param>
public static void AudioUpdate( GameObject target, float volume, float pitch,
float time ) {
AudioUpdate( target, Hash( "volume", volume, "pitch", pitch, "time",
time ) );
}
/// <summary>
/// Similar to RotateTo but incredibly less expensive for usage inside the
Update function or similar looping situations involving a "live" set of changing
values with FULL customization options. Does not utilize an EaseType.
/// </summary>
/// <param name="rotation">
/// A <see cref="Transform"/> or <see cref="Vector3"/> for the target Euler
angles in degrees to rotate to.
/// </param>
/// <param name="x">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
individual setting of the x axis.
/// </param>
/// <param name="y">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
individual setting of the y axis.
/// </param>
/// <param name="z">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
individual setting of the z axis.
/// </param>
/// <param name="islocal">
/// A <see cref="System.Boolean"/> for whether to animate in world space or
relative to the parent. False by default.
/// </param>
/// <param name="time">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time
in seconds the animation will take to complete.
/// </param>
public static void RotateUpdate( GameObject target, Hashtable args ) {
CleanArgs( args );
bool isLocal;
float time;
Vector3[] vector3s = new Vector3[ 4 ];
Vector3 preUpdate = target.transform.eulerAngles;
//set isLocal:
if ( args.Contains( "islocal" ) ) {
isLocal = (bool)args[ "islocal" ];
} else {
isLocal = Defaults.isLocal;
}
//from values:
if ( isLocal ) {
vector3s[ 0 ] = target.transform.localEulerAngles;
} else {
vector3s[ 0 ] = target.transform.eulerAngles;
}
//set to:
if ( args.Contains( "rotation" ) ) {
if ( args[ "rotation" ].GetType() == typeof( Transform ) ) {
Transform trans = (Transform)args[ "rotation" ];
vector3s[ 1 ] = trans.eulerAngles;
} else if ( args[ "rotation" ].GetType() == typeof( Vector3 ) ) {
vector3s[ 1 ] = (Vector3)args[ "rotation" ];
}
}
//calculate:
vector3s[ 3 ].x = Mathf.SmoothDampAngle( vector3s[ 0 ].x,
vector3s[ 1 ].x, ref vector3s[ 2 ].x, time );
vector3s[ 3 ].y = Mathf.SmoothDampAngle( vector3s[ 0 ].y,
vector3s[ 1 ].y, ref vector3s[ 2 ].y, time );
vector3s[ 3 ].z = Mathf.SmoothDampAngle( vector3s[ 0 ].z,
vector3s[ 1 ].z, ref vector3s[ 2 ].z, time );
//apply:
if ( isLocal ) {
target.transform.localEulerAngles = vector3s[ 3 ];
} else {
target.transform.eulerAngles = vector3s[ 3 ];
}
//need physics?
if ( target.GetComponent<Rigidbody>() != null ) {
Vector3 postUpdate = target.transform.eulerAngles;
target.transform.eulerAngles = preUpdate;
/// <summary>
/// Similar to RotateTo but incredibly less expensive for usage inside the
Update function or similar looping situations involving a "live" set of changing
values with MINIMUM customization options. Does not utilize an EaseType.
/// </summary>
/// <param name="target">
/// A <see cref="GameObject"/> to be the target of the animation.
/// </param>
/// <param name="rotation">
/// A <see cref="Vector3"/> for the target Euler angles in degrees to rotate
to.
/// </param>
/// <param name="time">
/// A <see cref="System.Single"/> for the time in seconds the animation will
take to complete.
/// </param>
public static void RotateUpdate( GameObject target, Vector3 rotation, float
time ) {
RotateUpdate( target, Hash( "rotation", rotation, "time", time ) );
}
/// <summary>
/// Similar to ScaleTo but incredibly less expensive for usage inside the
Update function or similar looping situations involving a "live" set of changing
values with FULL customization options. Does not utilize an EaseType.
/// </summary>
/// <param name="scale">
/// A <see cref="Transform"/> or <see cref="Vector3"/> for the final scale.
/// </param>
/// <param name="x">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
individual setting of the x axis.
/// </param>
/// <param name="y">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
individual setting of the y axis.
/// </param>
/// <param name="z">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
individual setting of the z axis.
/// </param>
/// <param name="time">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time
in seconds the animation will take to complete.
/// </param>
public static void ScaleUpdate( GameObject target, Hashtable args ) {
CleanArgs( args );
float time;
Vector3[] vector3s = new Vector3[ 4 ];
//init values:
vector3s[ 0 ] = vector3s[ 1 ] = target.transform.localScale;
//to values:
if ( args.Contains( "scale" ) ) {
if ( args[ "scale" ].GetType() == typeof( Transform ) ) {
Transform trans = (Transform)args[ "scale" ];
vector3s[ 1 ] = trans.localScale;
} else if ( args[ "scale" ].GetType() == typeof( Vector3 ) ) {
vector3s[ 1 ] = (Vector3)args[ "scale" ];
}
} else {
if ( args.Contains( "x" ) ) {
vector3s[ 1 ].x = (float)args[ "x" ];
}
if ( args.Contains( "y" ) ) {
vector3s[ 1 ].y = (float)args[ "y" ];
}
if ( args.Contains( "z" ) ) {
vector3s[ 1 ].z = (float)args[ "z" ];
}
}
//calculate:
vector3s[ 3 ].x = Mathf.SmoothDamp( vector3s[ 0 ].x, vector3s[ 1 ].x,
ref vector3s[ 2 ].x, time );
vector3s[ 3 ].y = Mathf.SmoothDamp( vector3s[ 0 ].y, vector3s[ 1 ].y,
ref vector3s[ 2 ].y, time );
vector3s[ 3 ].z = Mathf.SmoothDamp( vector3s[ 0 ].z, vector3s[ 1 ].z,
ref vector3s[ 2 ].z, time );
//apply:
target.transform.localScale = vector3s[ 3 ];
}
/// <summary>
/// Similar to ScaleTo but incredibly less expensive for usage inside the
Update function or similar looping situations involving a "live" set of changing
values with MINIMUM customization options. Does not utilize an EaseType.
/// </summary>
/// <param name="target">
/// A <see cref="GameObject"/> to be the target of the animation.
/// </param>
/// <param name="scale">
/// A <see cref="Vector3"/> for the final scale.
/// </param>
/// <param name="time">
/// A <see cref="System.Single"/> for the time in seconds the animation will
take to complete.
/// </param>
public static void ScaleUpdate( GameObject target, Vector3 scale, float
time ) {
ScaleUpdate( target, Hash( "scale", scale, "time", time ) );
}
/// <summary>
/// Similar to MoveTo but incredibly less expensive for usage inside the
Update function or similar looping situations involving a "live" set of changing
values with FULL customization options. Does not utilize an EaseType.
/// </summary>
/// <param name="position">
/// A <see cref="Transform"/> or <see cref="Vector3"/> for a point in space
the GameObject will animate to.
/// </param>
/// <param name="x">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
individual setting of the x axis.
/// </param>
/// <param name="y">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
individual setting of the y axis.
/// </param>
/// <param name="z">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the
individual setting of the z axis.
/// </param>
/// <param name="time">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time
in seconds the animation will take to complete.
/// </param>
/// <param name="islocal">
/// A <see cref="System.Boolean"/> for whether to animate in world space or
relative to the parent. False by default.
/// </param>
/// <param name="orienttopath">
/// A <see cref="System.Boolean"/> for whether or not the GameObject will
orient to its direction of travel. False by default.
/// </param>
/// <param name="looktarget">
/// A <see cref="Vector3"/> or A <see cref="Transform"/> for a target the
GameObject will look at.
/// </param>
/// <param name="looktime">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time
in seconds the object will take to look at either the "looktarget" or
"orienttopath".
/// </param>
/// <param name="axis">
/// A <see cref="System.String"/>. Restricts rotation to the supplied axis
only.
/// </param>
public static void MoveUpdate( GameObject target, Hashtable args ) {
CleanArgs( args );
float time;
Vector3[] vector3s = new Vector3[ 4 ];
bool isLocal;
Vector3 preUpdate = target.transform.position;
//set isLocal:
if ( args.Contains( "islocal" ) ) {
isLocal = (bool)args[ "islocal" ];
} else {
isLocal = Defaults.isLocal;
}
//init values:
if ( isLocal ) {
vector3s[ 0 ] = vector3s[ 1 ] = target.transform.localPosition;
} else {
vector3s[ 0 ] = vector3s[ 1 ] = target.transform.position;
}
//to values:
if ( args.Contains( "position" ) ) {
if ( args[ "position" ].GetType() == typeof( Transform ) ) {
Transform trans = (Transform)args[ "position" ];
vector3s[ 1 ] = trans.position;
} else if ( args[ "position" ].GetType() == typeof( Vector3 ) ) {
vector3s[ 1 ] = (Vector3)args[ "position" ];
}
} else {
if ( args.Contains( "x" ) ) {
vector3s[ 1 ].x = (float)args[ "x" ];
}
if ( args.Contains( "y" ) ) {
vector3s[ 1 ].y = (float)args[ "y" ];
}
if ( args.Contains( "z" ) ) {
vector3s[ 1 ].z = (float)args[ "z" ];
}
}
//calculate:
vector3s[ 3 ].x = Mathf.SmoothDamp( vector3s[ 0 ].x, vector3s[ 1 ].x,
ref vector3s[ 2 ].x, time );
vector3s[ 3 ].y = Mathf.SmoothDamp( vector3s[ 0 ].y, vector3s[ 1 ].y,
ref vector3s[ 2 ].y, time );
vector3s[ 3 ].z = Mathf.SmoothDamp( vector3s[ 0 ].z, vector3s[ 1 ].z,
ref vector3s[ 2 ].z, time );
//look applications:
if ( args.Contains( "looktarget" ) ) {
iTween.LookUpdate( target, args );
}
//apply:
if ( isLocal ) {
target.transform.localPosition = vector3s[ 3 ];
} else {
target.transform.position = vector3s[ 3 ];
}
//need physics?
if ( target.GetComponent<Rigidbody>() != null ) {
Vector3 postUpdate = target.transform.position;
target.transform.position = preUpdate;
target.GetComponent<Rigidbody>().MovePosition( postUpdate );
}
}
/// <summary>
/// Similar to MoveTo but incredibly less expensive for usage inside the
Update function or similar looping situations involving a "live" set of changing
values with MINIMUM customization options. Does not utilize an EaseType.
/// </summary>
/// <param name="target">
/// A <see cref="GameObject"/> to be the target of the animation.
/// </param>
/// <param name="position">
/// A <see cref="Vector3"/> for a point in space the GameObject will animate
to.
/// </param>
/// <param name="time">
/// A <see cref="System.Single"/> for the time in seconds the animation will
take to complete.
/// </param>
public static void MoveUpdate( GameObject target, Vector3 position, float
time ) {
MoveUpdate( target, Hash( "position", position, "time", time ) );
}
/// <summary>
/// Similar to LookTo but incredibly less expensive for usage inside the
Update function or similar looping situations involving a "live" set of changing
values with FULL customization options. Does not utilize an EaseType.
/// </summary>
/// <param name="looktarget">
/// A <see cref="Transform"/> or <see cref="Vector3"/> for a target the
GameObject will look at.
/// </param>
/// <param name="axis">
/// A <see cref="System.String"/>. Restricts rotation to the supplied axis
only.
/// </param>
/// <param name="time">
/// A <see cref="System.Single"/> or <see cref="System.Double"/> for the time
in seconds the animation will take to complete.
/// </param>
public static void LookUpdate( GameObject target, Hashtable args ) {
CleanArgs( args );
float time;
Vector3[] vector3s = new Vector3[ 5 ];
//from values:
vector3s[ 0 ] = target.transform.eulerAngles;
//set look:
if ( args.Contains( "looktarget" ) ) {
if ( args[ "looktarget" ].GetType() == typeof( Transform ) ) {
//target.transform.LookAt((Transform)args["looktarget"]);
target.transform.LookAt( (Transform)args[ "looktarget" ],
(Vector3?)args[ "up" ] ?? Defaults.up );
} else if ( args[ "looktarget" ].GetType() == typeof( Vector3 ) )
{
//target.transform.LookAt((Vector3)args["looktarget"]);
target.transform.LookAt( (Vector3)args[ "looktarget" ],
(Vector3?)args[ "up" ] ?? Defaults.up );
}
} else {
Debug.LogError( "iTween Error: LookUpdate needs a 'looktarget'
property!" );
return;
}
//calculate:
vector3s[ 3 ].x = Mathf.SmoothDampAngle( vector3s[ 0 ].x,
vector3s[ 1 ].x, ref vector3s[ 2 ].x, time );
vector3s[ 3 ].y = Mathf.SmoothDampAngle( vector3s[ 0 ].y,
vector3s[ 1 ].y, ref vector3s[ 2 ].y, time );
vector3s[ 3 ].z = Mathf.SmoothDampAngle( vector3s[ 0 ].z,
vector3s[ 1 ].z, ref vector3s[ 2 ].z, time );
//apply:
target.transform.eulerAngles = vector3s[ 3 ];
//axis restriction:
if ( args.Contains( "axis" ) ) {
vector3s[ 4 ] = target.transform.eulerAngles;
switch ( (string)args[ "axis" ] ) {
case "x":
vector3s[ 4 ].y = vector3s[ 0 ].y;
vector3s[ 4 ].z = vector3s[ 0 ].z;
break;
case "y":
vector3s[ 4 ].x = vector3s[ 0 ].x;
vector3s[ 4 ].z = vector3s[ 0 ].z;
break;
case "z":
vector3s[ 4 ].x = vector3s[ 0 ].x;
vector3s[ 4 ].y = vector3s[ 0 ].y;
break;
}
/// <summary>
/// Similar to LookTo but incredibly less expensive for usage inside the
Update function or similar looping situations involving a "live" set of changing
values with FULL customization options. Does not utilize an EaseType.
/// </summary>
/// <param name="target">
/// A <see cref="GameObject"/> to be the target of the animation.
/// </param>
/// <param name="looktarget">
/// A <see cref="Vector3"/> for a target the GameObject will look at.
/// </param>
/// <param name="time">
/// A <see cref="System.Single"/> for the time in seconds the animation will
take to complete.
/// </param>
public static void LookUpdate( GameObject target, Vector3 looktarget, float
time ) {
LookUpdate( target, Hash( "looktarget", looktarget, "time", time ) );
}
#endregion
#region #7 External Utilities
/// <summary>
/// Returns the length of a curved path drawn through the provided array of
Transforms.
/// </summary>
/// <returns>
/// A <see cref="System.Single"/>
/// </returns>
/// <param name='path'>
/// A <see cref="Transform[]"/>
/// </param>
public static float PathLength( Transform[] path ) {
Vector3[] suppliedPath = new Vector3[ path.Length ];
float pathLength = 0;
//Line Draw:
Vector3 prevPt = Interp( vector3s, 0 );
int SmoothAmount = path.Length * 20;
for ( int i = 1; i <= SmoothAmount; i++ ) {
float pm = (float)i / SmoothAmount;
Vector3 currPt = Interp( vector3s, pm );
pathLength += Vector3.Distance( prevPt, currPt );
prevPt = currPt;
}
return pathLength;
}
/// <summary>
/// Returns the length of a curved path drawn through the provided array of
Vector3s.
/// </summary>
/// <returns>
/// The length.
/// </returns>
/// <param name='path'>
/// A <see cref="Vector3[]"/>
/// </param>
public static float PathLength( Vector3[] path ) {
float pathLength = 0;
//Line Draw:
Vector3 prevPt = Interp( vector3s, 0 );
int SmoothAmount = path.Length * 20;
for ( int i = 1; i <= SmoothAmount; i++ ) {
float pm = (float)i / SmoothAmount;
Vector3 currPt = Interp( vector3s, pm );
pathLength += Vector3.Distance( prevPt, currPt );
prevPt = currPt;
}
return pathLength;
}
/// <summary>
/// Creates and returns a full-screen Texture2D for use with CameraFade.
/// </summary>
/// <returns>
/// Texture2D
/// </returns>
/// <param name='color'>
/// Color
/// </param>
public static Texture2D CameraTexture( Color color ) {
Texture2D texture = new Texture2D( Screen.width, Screen.height,
TextureFormat.ARGB32, false );
Color[] colors = new Color[ Screen.width * Screen.height ];
for ( int i = 0; i < colors.Length; i++ ) {
colors[ i ] = color;
}
texture.SetPixels( colors );
texture.Apply();
return ( texture );
}
/// <summary>
/// Puts a GameObject on a path at the provided percentage
/// </summary>
/// <param name="target">
/// A <see cref="GameObject"/>
/// </param>
/// <param name="path">
/// A <see cref="Vector3[]"/>
/// </param>
/// <param name="percent">
/// A <see cref="System.Single"/>
/// </param>
public static void PutOnPath( GameObject target, Vector3[] path, float
percent ) {
target.transform.position = Interp( PathControlPointGenerator( path ),
percent );
}
/// <summary>
/// Puts a GameObject on a path at the provided percentage
/// </summary>
/// <param name="target">
/// A <see cref="Transform"/>
/// </param>
/// <param name="path">
/// A <see cref="Vector3[]"/>
/// </param>
/// <param name="percent">
/// A <see cref="System.Single"/>
/// </param>
public static void PutOnPath( Transform target, Vector3[] path, float percent
) {
target.position = Interp( PathControlPointGenerator( path ), percent );
}
/// <summary>
/// Puts a GameObject on a path at the provided percentage
/// </summary>
/// <param name="target">
/// A <see cref="GameObject"/>
/// </param>
/// <param name="path">
/// A <see cref="Transform[]"/>
/// </param>
/// <param name="percent">
/// A <see cref="System.Single"/>
/// </param>
public static void PutOnPath( GameObject target, Transform[] path, float
percent ) {
//create and store path points:
Vector3[] suppliedPath = new Vector3[ path.Length ];
for ( int i = 0; i < path.Length; i++ ) {
suppliedPath[ i ] = path[ i ].position;
}
target.transform.position =
Interp( PathControlPointGenerator( suppliedPath ), percent );
}
/// <summary>
/// Puts a GameObject on a path at the provided percentage
/// </summary>
/// <param name="target">
/// A <see cref="Transform"/>
/// </param>
/// <param name="path">
/// A <see cref="Transform[]"/>
/// </param>
/// <param name="percent">
/// A <see cref="System.Single"/>
/// </param>
public static void PutOnPath( Transform target, Transform[] path, float
percent ) {
//create and store path points:
Vector3[] suppliedPath = new Vector3[ path.Length ];
for ( int i = 0; i < path.Length; i++ ) {
suppliedPath[ i ] = path[ i ].position;
}
target.position = Interp( PathControlPointGenerator( suppliedPath ),
percent );
}
/// <summary>
/// Returns a Vector3 position on a path at the provided percentage
/// </summary>
/// <param name="path">
/// A <see cref="Transform[]"/>
/// </param>
/// <param name="percent">
/// A <see cref="System.Single"/>
/// </param>
/// <returns>
/// A <see cref="Vector3"/>
/// </returns>
public static Vector3 PointOnPath( Transform[] path, float percent ) {
//create and store path points:
Vector3[] suppliedPath = new Vector3[ path.Length ];
for ( int i = 0; i < path.Length; i++ ) {
suppliedPath[ i ] = path[ i ].position;
}
return ( Interp( PathControlPointGenerator( suppliedPath ),
percent ) );
}
/// <summary>
/// When called from an OnDrawGizmos() function it will draw a line through
the provided array of Vector3s.
/// </summary>
/// <param name="line">
/// A <see cref="Vector3s[]"/>
/// </param>
public static void DrawLine( Vector3[] line ) {
if ( line.Length > 0 ) {
DrawLineHelper( line, Defaults.color, "gizmos" );
}
}
/// <summary>
/// When called from an OnDrawGizmos() function it will draw a line through
the provided array of Vector3s.
/// </summary>
/// <param name="line">
/// A <see cref="Vector3s[]"/>
/// </param>
/// <param name="color">
/// A <see cref="Color"/>
/// </param>
public static void DrawLine( Vector3[] line, Color color ) {
if ( line.Length > 0 ) {
DrawLineHelper( line, color, "gizmos" );
}
}
/// <summary>
/// When called from an OnDrawGizmos() function it will draw a line through
the provided array of Transforms.
/// </summary>
/// <param name="line">
/// A <see cref="Transform[]"/>
/// </param>
public static void DrawLine( Transform[] line ) {
if ( line.Length > 0 ) {
//create and store line points:
Vector3[] suppliedLine = new Vector3[ line.Length ];
for ( int i = 0; i < line.Length; i++ ) {
suppliedLine[ i ] = line[ i ].position;
}
DrawLineHelper( suppliedLine, Defaults.color, "gizmos" );
}
}
/// <summary>
/// When called from an OnDrawGizmos() function it will draw a line through
the provided array of Transforms.
/// </summary>
/// <param name="line">
/// A <see cref="Transform[]"/>
/// </param>
/// <param name="color">
/// A <see cref="Color"/>
/// </param>
public static void DrawLine( Transform[] line, Color color ) {
if ( line.Length > 0 ) {
//create and store line points:
Vector3[] suppliedLine = new Vector3[ line.Length ];
for ( int i = 0; i < line.Length; i++ ) {
suppliedLine[ i ] = line[ i ].position;
}
/// <summary>
/// Draws a line through the provided array of Vector3s with
Gizmos.DrawLine().
/// </summary>
/// <param name="line">
/// A <see cref="Vector3s[]"/>
/// </param>
public static void DrawLineGizmos( Vector3[] line ) {
if ( line.Length > 0 ) {
DrawLineHelper( line, Defaults.color, "gizmos" );
}
}
/// <summary>
/// Draws a line through the provided array of Vector3s with
Gizmos.DrawLine().
/// </summary>
/// <param name="line">
/// A <see cref="Vector3s[]"/>
/// </param>
/// <param name="color">
/// A <see cref="Color"/>
/// </param>
public static void DrawLineGizmos( Vector3[] line, Color color ) {
if ( line.Length > 0 ) {
DrawLineHelper( line, color, "gizmos" );
}
}
/// <summary>
/// Draws a line through the provided array of Transforms with
Gizmos.DrawLine().
/// </summary>
/// <param name="line">
/// A <see cref="Transform[]"/>
/// </param>
public static void DrawLineGizmos( Transform[] line ) {
if ( line.Length > 0 ) {
//create and store line points:
Vector3[] suppliedLine = new Vector3[ line.Length ];
for ( int i = 0; i < line.Length; i++ ) {
suppliedLine[ i ] = line[ i ].position;
}
DrawLineHelper( suppliedLine, Defaults.color, "gizmos" );
}
}
/// <summary>
/// Draws a line through the provided array of Transforms with
Gizmos.DrawLine().
/// </summary>
/// <param name="line">
/// A <see cref="Transform[]"/>
/// </param>
/// <param name="color">
/// A <see cref="Color"/>
/// </param>
public static void DrawLineGizmos( Transform[] line, Color color ) {
if ( line.Length > 0 ) {
//create and store line points:
Vector3[] suppliedLine = new Vector3[ line.Length ];
for ( int i = 0; i < line.Length; i++ ) {
suppliedLine[ i ] = line[ i ].position;
}
/// <summary>
/// Draws a line through the provided array of Vector3s with
Handles.DrawLine().
/// </summary>
/// <param name="line">
/// A <see cref="Vector3s[]"/>
/// </param>
public static void DrawLineHandles( Vector3[] line ) {
if ( line.Length > 0 ) {
DrawLineHelper( line, Defaults.color, "handles" );
}
}
/// <summary>
/// Draws a line through the provided array of Vector3s with
Handles.DrawLine().
/// </summary>
/// <param name="line">
/// A <see cref="Vector3s[]"/>
/// </param>
/// <param name="color">
/// A <see cref="Color"/>
/// </param>
public static void DrawLineHandles( Vector3[] line, Color color ) {
if ( line.Length > 0 ) {
DrawLineHelper( line, color, "handles" );
}
}
/// <summary>
/// Draws a line through the provided array of Transforms with
Handles.DrawLine().
/// </summary>
/// <param name="line">
/// A <see cref="Transform[]"/>
/// </param>
public static void DrawLineHandles( Transform[] line ) {
if ( line.Length > 0 ) {
//create and store line points:
Vector3[] suppliedLine = new Vector3[ line.Length ];
for ( int i = 0; i < line.Length; i++ ) {
suppliedLine[ i ] = line[ i ].position;
}
DrawLineHelper( suppliedLine, Defaults.color, "handles" );
}
}
/// <summary>
/// Draws a line through the provided array of Transforms with
Handles.DrawLine().
/// </summary>
/// <param name="line">
/// A <see cref="Transform[]"/>
/// </param>
/// <param name="color">
/// A <see cref="Color"/>
/// </param>
public static void DrawLineHandles( Transform[] line, Color color ) {
if ( line.Length > 0 ) {
//create and store line points:
Vector3[] suppliedLine = new Vector3[ line.Length ];
for ( int i = 0; i < line.Length; i++ ) {
suppliedLine[ i ] = line[ i ].position;
}
/// <summary>
/// Returns a Vector3 position on a path at the provided percentage
/// </summary>
/// <param name="path">
/// A <see cref="Vector3[]"/>
/// </param>
/// <param name="percent">
/// A <see cref="System.Single"/>
/// </param>
/// <returns>
/// A <see cref="Vector3"/>
/// </returns>
public static Vector3 PointOnPath( Vector3[] path, float percent ) {
return ( Interp( PathControlPointGenerator( path ), percent ) );
}
/// <summary>
/// When called from an OnDrawGizmos() function it will draw a curved path
through the provided array of Vector3s.
/// </summary>
/// <param name="path">
/// A <see cref="Vector3s[]"/>
/// </param>
public static void DrawPath( Vector3[] path ) {
if ( path.Length > 0 ) {
DrawPathHelper( path, Defaults.color, "gizmos" );
}
}
/// <summary>
/// When called from an OnDrawGizmos() function it will draw a curved path
through the provided array of Vector3s.
/// </summary>
/// <param name="path">
/// A <see cref="Vector3s[]"/>
/// </param>
/// <param name="color">
/// A <see cref="Color"/>
/// </param>
public static void DrawPath( Vector3[] path, Color color ) {
if ( path.Length > 0 ) {
DrawPathHelper( path, color, "gizmos" );
}
}
/// <summary>
/// When called from an OnDrawGizmos() function it will draw a curved path
through the provided array of Transforms.
/// </summary>
/// <param name="path">
/// A <see cref="Transform[]"/>
/// </param>
public static void DrawPath( Transform[] path ) {
if ( path.Length > 0 ) {
//create and store path points:
Vector3[] suppliedPath = new Vector3[ path.Length ];
for ( int i = 0; i < path.Length; i++ ) {
suppliedPath[ i ] = path[ i ].position;
}
/// <summary>
/// When called from an OnDrawGizmos() function it will draw a curved path
through the provided array of Transforms.
/// </summary>
/// <param name="path">
/// A <see cref="Transform[]"/>
/// </param>
/// <param name="color">
/// A <see cref="Color"/>
/// </param>
public static void DrawPath( Transform[] path, Color color ) {
if ( path.Length > 0 ) {
//create and store path points:
Vector3[] suppliedPath = new Vector3[ path.Length ];
for ( int i = 0; i < path.Length; i++ ) {
suppliedPath[ i ] = path[ i ].position;
}
/// <summary>
/// Draws a curved path through the provided array of Vector3s with
Gizmos.DrawLine().
/// </summary>
/// <param name="path">
/// A <see cref="Vector3s[]"/>
/// </param>
public static void DrawPathGizmos( Vector3[] path ) {
if ( path.Length > 0 ) {
DrawPathHelper( path, Defaults.color, "gizmos" );
}
}
/// <summary>
/// Draws a curved path through the provided array of Vector3s with
Gizmos.DrawLine().
/// </summary>
/// <param name="path">
/// A <see cref="Vector3s[]"/>
/// </param>
/// <param name="color">
/// A <see cref="Color"/>
/// </param>
public static void DrawPathGizmos( Vector3[] path, Color color ) {
if ( path.Length > 0 ) {
DrawPathHelper( path, color, "gizmos" );
}
}
/// <summary>
/// Draws a curved path through the provided array of Transforms with
Gizmos.DrawLine().
/// </summary>
/// <param name="path">
/// A <see cref="Transform[]"/>
/// </param>
public static void DrawPathGizmos( Transform[] path ) {
if ( path.Length > 0 ) {
//create and store path points:
Vector3[] suppliedPath = new Vector3[ path.Length ];
for ( int i = 0; i < path.Length; i++ ) {
suppliedPath[ i ] = path[ i ].position;
}
/// <summary>
/// Draws a curved path through the provided array of Transforms with
Gizmos.DrawLine().
/// </summary>
/// <param name="path">
/// A <see cref="Transform[]"/>
/// </param>
/// <param name="color">
/// A <see cref="Color"/>
/// </param>
public static void DrawPathGizmos( Transform[] path, Color color ) {
if ( path.Length > 0 ) {
//create and store path points:
Vector3[] suppliedPath = new Vector3[ path.Length ];
for ( int i = 0; i < path.Length; i++ ) {
suppliedPath[ i ] = path[ i ].position;
}
/// <summary>
/// Draws a curved path through the provided array of Vector3s with
Handles.DrawLine().
/// </summary>
/// <param name="path">
/// A <see cref="Vector3s[]"/>
/// </param>
public static void DrawPathHandles( Vector3[] path ) {
if ( path.Length > 0 ) {
DrawPathHelper( path, Defaults.color, "handles" );
}
}
/// <summary>
/// Draws a curved path through the provided array of Vector3s with
Handles.DrawLine().
/// </summary>
/// <param name="path">
/// A <see cref="Vector3s[]"/>
/// </param>
/// <param name="color">
/// A <see cref="Color"/>
/// </param>
public static void DrawPathHandles( Vector3[] path, Color color ) {
if ( path.Length > 0 ) {
DrawPathHelper( path, color, "handles" );
}
}
/// <summary>
/// Draws a curved path through the provided array of Transforms with
Handles.DrawLine().
/// </summary>
/// <param name="path">
/// A <see cref="Transform[]"/>
/// </param>
public static void DrawPathHandles( Transform[] path ) {
if ( path.Length > 0 ) {
//create and store path points:
Vector3[] suppliedPath = new Vector3[ path.Length ];
for ( int i = 0; i < path.Length; i++ ) {
suppliedPath[ i ] = path[ i ].position;
}
/// <summary>
/// Draws a curved path through the provided array of Transforms with
Handles.DrawLine().
/// </summary>
/// <param name="path">
/// A <see cref="Transform[]"/>
/// </param>
/// <param name="color">
/// A <see cref="Color"/>
/// </param>
public static void DrawPathHandles( Transform[] path, Color color ) {
if ( path.Length > 0 ) {
//create and store path points:
Vector3[] suppliedPath = new Vector3[ path.Length ];
for ( int i = 0; i < path.Length; i++ ) {
suppliedPath[ i ] = path[ i ].position;
}
/// <summary>
/// Changes a camera fade's texture.
/// </summary>
/// <param name="depth">
/// A <see cref="System.Int32"/>
/// </param>
public static void CameraFadeDepth( int depth ) {
if ( cameraFade ) {
cameraFade.transform.position = new
Vector3( cameraFade.transform.position.x, cameraFade.transform.position.y, depth );
}
}
/// <summary>
/// Removes and destroyes a camera fade.
/// </summary>
public static void CameraFadeDestroy() {
if ( cameraFade ) {
Destroy( cameraFade );
}
}
/// <summary>
/// Changes a camera fade's texture.
/// </summary>
/// <param name='texture'>
/// A <see cref="Texture2D"/>
/// </param>
public static void CameraFadeSwap(Texture2D texture)
{
if(cameraFade)
{
var newSprite = Sprite.Create(texture, new Rect(0.0f, 0.0f,
texture.width, texture.height), Vector2.one * 0.5f);
cameraFade.GetComponent<Image>().sprite = newSprite;
}
}
}
/// <summary>
/// Creates a GameObject (if it doesn't exist) at the supplied depth that can
be used to simulate a camera fade.
/// </summary>
/// <param name='texture'>
/// A <see cref="Texture2D"/>
/// </param>
/// <param name='depth'>
/// A <see cref="System.Int32"/>
/// </param>
/// <returns>
/// A <see cref="GameObject"/> for a reference to the CameraFade.
/// </returns>
public static GameObject CameraFadeAdd( Texture2D texture, int depth ) {
if ( cameraFade ) {
return null;
} else {
//establish colorFade object:
cameraFade = new GameObject( "iTween Camera Fade" );
cameraFade.transform.position = new Vector3( .5f, .5f, depth );
cameraFade.AddComponent<Image>();
cameraFade.GetComponent<Image>().texture = texture;
cameraFade.GetComponent<Image>().color = new
Color( .5f, .5f, .5f, 0 );
return cameraFade;
}
}
/// <summary>
/// Creates a GameObject (if it doesn't exist) at the default depth that can
be used to simulate a camera fade.
/// </summary>
/// <param name='texture'>
/// A <see cref="Texture2D"/>
/// </param>
/// <returns>
/// A <see cref="GameObject"/> for a reference to the CameraFade.
/// </returns>
public static GameObject CameraFadeAdd( Texture2D texture ) {
if ( cameraFade ) {
return null;
} else {
//establish colorFade object:
cameraFade = new GameObject( "iTween Camera Fade" );
cameraFade.transform.position = new Vector3( .5f, .5f,
Defaults.cameraFadeDepth );
cameraFade.AddComponent<Image>();
cameraFade.GetComponent<Image>().texture = texture;
cameraFade.GetComponent<Image>().color = new
Color( .5f, .5f, .5f, 0 );
return cameraFade;
}
}
/// <summary>
/// Creates a GameObject (if it doesn't exist) at the default depth filled
with black that can be used to simulate a camera fade.
/// </summary>
/// <returns>
/// A <see cref="GameObject"/> for a reference to the CameraFade.
/// </returns>
public static GameObject CameraFadeAdd() {
if ( cameraFade ) {
return null;
} else {
//establish colorFade object:
cameraFade = new GameObject( "iTween Camera Fade" );
cameraFade.transform.position = new Vector3( .5f, .5f,
Defaults.cameraFadeDepth );
cameraFade.AddComponent<Image>();
cameraFade.GetComponent<Image>().texture =
CameraTexture( Color.black );
cameraFade.GetComponent<Image>().color = new
Color( .5f, .5f, .5f, 0 );
return cameraFade;
}
}
//#################################
//# RESUME UTILITIES AND OVERLOADS #
//#################################
/// <summary>
/// Resume all iTweens on a GameObject.
/// </summary>
public static void Resume( GameObject target ) {
Component[] tweens = target.GetComponents<iTween>();
foreach ( iTween item in tweens ) {
item.enabled = true;
}
}
/// <summary>
/// Resume all iTweens on a GameObject including its children.
/// </summary>
public static void Resume( GameObject target, bool includechildren ) {
Resume( target );
if ( includechildren ) {
foreach ( Transform child in target.transform ) {
Resume( child.gameObject, true );
}
}
}
/// <summary>
/// Resume all iTweens on a GameObject of a particular type.
/// </summar
/// <param name="type">
/// A <see cref="System.String"/> name of the type of iTween you would like
to resume. Can be written as part of a name such as "mov" for all "MoveTo"
iTweens.
/// </param>
public static void Resume( GameObject target, string type ) {
Component[] tweens = target.GetComponents<iTween>();
foreach ( iTween item in tweens ) {
string targetType = item.type + item.method;
targetType = targetType.Substring( 0, type.Length );
if ( targetType.ToLower() == type.ToLower() ) {
item.enabled = true;
}
}
}
/// <summary>
/// Resume all iTweens on a GameObject of a particular type including its
children.
/// </summar
/// <param name="type">
/// A <see cref="System.String"/> name of the type of iTween you would like
to resume. Can be written as part of a name such as "mov" for all "MoveTo"
iTweens.
/// </param>
public static void Resume( GameObject target, string type, bool
includechildren ) {
Component[] tweens = target.GetComponents<iTween>();
foreach ( iTween item in tweens ) {
string targetType = item.type + item.method;
targetType = targetType.Substring( 0, type.Length );
if ( targetType.ToLower() == type.ToLower() ) {
item.enabled = true;
}
}
if ( includechildren ) {
foreach ( Transform child in target.transform ) {
Resume( child.gameObject, type, true );
}
}
}
/// <summary>
/// Resume all iTweens in scene.
/// </summary>
public static void Resume() {
for ( int i = 0; i < tweens.Count; i++ ) {
Hashtable currentTween = tweens[ i ];
GameObject target = (GameObject)currentTween[ "target" ];
Resume( target );
}
}
/// <summary>
/// Resume all iTweens in scene of a particular type.
/// </summary>
/// <param name="type">
/// A <see cref="System.String"/> name of the type of iTween you would like
to resume. Can be written as part of a name such as "mov" for all "MoveTo"
iTweens.
/// </param>
public static void Resume( string type ) {
ArrayList resumeArray = new ArrayList();
//#################################
//# PAUSE UTILITIES AND OVERLOADS #
//#################################
/// <summary>
/// Pause all iTweens on a GameObject.
/// </summary>
public static void Pause( GameObject target ) {
Component[] tweens = target.GetComponents<iTween>();
foreach ( iTween item in tweens ) {
if ( item.delay > 0 ) {
item.delay -= Time.time - item.delayStarted;
item.StopCoroutine( "TweenDelay" );
}
item.isPaused = true;
item.enabled = false;
}
}
/// <summary>
/// Pause all iTweens on a GameObject including its children.
/// </summary>
public static void Pause( GameObject target, bool includechildren ) {
Pause( target );
if ( includechildren ) {
foreach ( Transform child in target.transform ) {
Pause( child.gameObject, true );
}
}
}
/// <summary>
/// Pause all iTweens on a GameObject of a particular type.
/// </summar
/// <param name="type">
/// A <see cref="System.String"/> name of the type of iTween you would like
to pause. Can be written as part of a name such as "mov" for all "MoveTo" iTweens.
/// </param>
public static void Pause( GameObject target, string type ) {
Component[] tweens = target.GetComponents<iTween>();
foreach ( iTween item in tweens ) {
string targetType = item.type + item.method;
targetType = targetType.Substring( 0, type.Length );
if ( targetType.ToLower() == type.ToLower() ) {
if ( item.delay > 0 ) {
item.delay -= Time.time - item.delayStarted;
item.StopCoroutine( "TweenDelay" );
}
item.isPaused = true;
item.enabled = false;
}
}
}
/// <summary>
/// Pause all iTweens on a GameObject of a particular type including its
children.
/// </summar
/// <param name="type">
/// A <see cref="System.String"/> name of the type of iTween you would like
to pause. Can be written as part of a name such as "mov" for all "MoveTo" iTweens.
/// </param>
public static void Pause( GameObject target, string type, bool
includechildren ) {
Component[] tweens = target.GetComponents<iTween>();
foreach ( iTween item in tweens ) {
string targetType = item.type + item.method;
targetType = targetType.Substring( 0, type.Length );
if ( targetType.ToLower() == type.ToLower() ) {
if ( item.delay > 0 ) {
item.delay -= Time.time - item.delayStarted;
item.StopCoroutine( "TweenDelay" );
}
item.isPaused = true;
item.enabled = false;
}
}
if ( includechildren ) {
foreach ( Transform child in target.transform ) {
Pause( child.gameObject, type, true );
}
}
}
/// <summary>
/// Pause all iTweens in scene.
/// </summary>
public static void Pause() {
for ( int i = 0; i < tweens.Count; i++ ) {
Hashtable currentTween = tweens[ i ];
GameObject target = (GameObject)currentTween[ "target" ];
Pause( target );
}
}
/// <summary>
/// Pause all iTweens in scene of a particular type.
/// </summary>
/// <param name="type">
/// A <see cref="System.String"/> name of the type of iTween you would like
to pause. Can be written as part of a name such as "mov" for all "MoveTo" iTweens.
/// </param>
public static void Pause( string type ) {
ArrayList pauseArray = new ArrayList();
//#################################
//# COUNT UTILITIES AND OVERLOADS #
//#################################
/// <summary>
/// Count all iTweens in current scene.
/// </summary>
public static int Count() {
return ( tweens.Count );
}
/// <summary>
/// Count all iTweens in current scene of a particular type.
/// </summary>
/// <param name="type">
/// A <see cref="System.String"/> name of the type of iTween you would like
to stop. Can be written as part of a name such as "mov" for all "MoveTo" iTweens.
/// </param>
public static int Count( string type ) {
int tweenCount = 0;
return ( tweenCount );
}
/// <summary>
/// Count all iTweens on a GameObject.
/// </summary>
public static int Count( GameObject target ) {
Component[] tweens = target.GetComponents<iTween>();
return ( tweens.Length );
}
/// <summary>
/// Count all iTweens on a GameObject of a particular type.
/// </summary>
/// <param name="type">
/// A <see cref="System.String"/> name of the type of iTween you would like
to count. Can be written as part of a name such as "mov" for all "MoveTo" iTweens.
/// </param>
public static int Count( GameObject target, string type ) {
int tweenCount = 0;
Component[] tweens = target.GetComponents<iTween>();
foreach ( iTween item in tweens ) {
string targetType = item.type + item.method;
targetType = targetType.Substring( 0, type.Length );
if ( targetType.ToLower() == type.ToLower() ) {
tweenCount++;
}
}
return ( tweenCount );
}
//################################
//# STOP UTILITIES AND OVERLOADS #
//################################
/// <summary>
/// Stop and destroy all Tweens in current scene.
/// </summary>
public static void Stop() {
for ( int i = 0; i < tweens.Count; i++ ) {
Hashtable currentTween = tweens[ i ];
GameObject target = (GameObject)currentTween[ "target" ];
Stop( target );
}
tweens.Clear();
}
/// <summary>
/// Stop and destroy all iTweens in current scene of a particular type.
/// </summary>
/// <param name="type">
/// A <see cref="System.String"/> name of the type of iTween you would like
to stop. Can be written as part of a name such as "mov" for all "MoveTo" iTweens.
/// </param>
public static void Stop( string type ) {
ArrayList stopArray = new ArrayList();
/// <summary>
/// Stop and destroy all iTweens on a GameObject.
/// </summary>
public static void Stop( GameObject target ) {
Component[] tweens = target.GetComponents<iTween>();
foreach ( iTween item in tweens ) {
item.Dispose();
}
}
/// <summary>
/// Stop and destroy all iTweens on a GameObject including its children.
/// </summary>
public static void Stop( GameObject target, bool includechildren ) {
Stop( target );
if ( includechildren ) {
foreach ( Transform child in target.transform ) {
Stop( child.gameObject, true );
}
}
}
/// <summary>
/// Stop and destroy all iTweens on a GameObject of a particular type.
/// </summar
/// <param name="type">
/// A <see cref="System.String"/> name of the type of iTween you would like
to stop. Can be written as part of a name such as "mov" for all "MoveTo" iTweens.
/// </param>
public static void Stop( GameObject target, string type ) {
Component[] tweens = target.GetComponents<iTween>();
foreach ( iTween item in tweens ) {
string targetType = item.type + item.method;
targetType = targetType.Substring( 0, type.Length );
if ( targetType.ToLower() == type.ToLower() ) {
item.Dispose();
}
}
}
/* GFX47 MOD START */
/// <summary>
/// Stop and destroy all iTweens on a GameObject of a particular name.
/// </summar
/// <param name="name">
/// The <see cref="System.String"/> name of iTween you would like to stop.
/// </param>
public static void StopByName( GameObject target, string name ) {
Component[] tweens = target.GetComponents<iTween>();
foreach ( iTween item in tweens ) {
/*string targetType = item.type+item.method;
targetType=targetType.Substring(0,type.Length);
if(targetType.ToLower() == type.ToLower()){
item.Dispose();
}*/
if ( item._name == name ) {
item.Dispose();
}
}
}
/* GFX47 MOD END */
/// <summary>
/// Stop and destroy all iTweens on a GameObject of a particular type
including its children.
/// </summar
/// <param name="type">
/// A <see cref="System.String"/> name of the type of iTween you would like
to stop. Can be written as part of a name such as "mov" for all "MoveTo" iTweens.
/// </param>
public static void Stop( GameObject target, string type, bool includechildren
) {
Component[] tweens = target.GetComponents<iTween>();
foreach ( iTween item in tweens ) {
string targetType = item.type + item.method;
targetType = targetType.Substring( 0, type.Length );
if ( targetType.ToLower() == type.ToLower() ) {
item.Dispose();
}
}
if ( includechildren ) {
foreach ( Transform child in target.transform ) {
Stop( child.gameObject, type, true );
}
}
}
/// <summary>
/// Universal interface to help in the creation of Hashtables. Especially
useful for C# users.
/// </summary>
/// <param name="args">
/// A <see cref="System.Object[]"/> of alternating name value pairs. For
example "time",1,"delay",2...
/// </param>
/// <returns>
/// A <see cref="Hashtable"/>
/// </returns>
public static Hashtable Hash( params object[] args ) {
Hashtable hashTable = new Hashtable( args.Length / 2 );
if ( args.Length % 2 != 0 ) {
Debug.LogError( "Tween Error: Hash requires an even number of
arguments!" );
return null;
} else {
int i = 0;
while ( i < args.Length - 1 ) {
hashTable.Add( args[ i ], args[ i + 1 ] );
i += 2;
}
return hashTable;
}
}
#endregion
void Awake() {
thisTransform = transform;
RetrieveArgs();
lastRealTime = Time.realtimeSinceStartup; // Added by PressPlay
}
IEnumerator Start() {
if ( delay > 0 ) {
yield return StartCoroutine( "TweenDelay" );
}
TweenStart();
}
//non-physics
void Update() {
if ( isRunning && !physics ) {
if ( !reverse ) {
if ( percentage < 1f ) {
TweenUpdate();
} else {
TweenComplete();
}
} else {
if ( percentage > 0 ) {
TweenUpdate();
} else {
TweenComplete();
}
}
}
}
//physics
void FixedUpdate() {
if ( isRunning && physics ) {
if ( !reverse ) {
if ( percentage < 1f ) {
TweenUpdate();
} else {
TweenComplete();
}
} else {
if ( percentage > 0 ) {
TweenUpdate();
} else {
TweenComplete();
}
}
}
}
void LateUpdate() {
//look applications:
if ( tweenArguments.Contains( "looktarget" ) && isRunning ) {
if ( type == "move" || type == "shake" || type == "punch" ) {
LookUpdate( gameObject, tweenArguments );
}
}
}
void OnEnable() {
if ( isRunning ) {
EnableKinematic();
}
//resume delay:
if ( isPaused ) {
isPaused = false;
if ( delay > 0 ) {
wasPaused = true;
ResumeDelay();
}
}
}
void OnDisable() {
DisableKinematic();
}
#endregion
//Line Draw:
Vector3 prevPt = Interp( vector3s, 0 );
Gizmos.color = color;
int SmoothAmount = path.Length * 20;
for ( int i = 1; i <= SmoothAmount; i++ ) {
float pm = (float)i / SmoothAmount;
Vector3 currPt = Interp( vector3s, pm );
if ( method == "gizmos" ) {
Gizmos.DrawLine( currPt, prevPt );
} else if ( method == "handles" ) {
Debug.LogError( "iTween Error: Drawing a path with Handles
is temporarily disabled because of compatability issues with Unity 2.6!" );
//UnityEditor.Handles.DrawLine(currPt, prevPt);
}
prevPt = currPt;
}
}
//is this a closed, continuous loop? yes? well then so let's make a
continuous Catmull-Rom spline!
if ( vector3s[ 1 ] == vector3s[ vector3s.Length - 2 ] ) {
Vector3[] tmpLoopSpline = new Vector3[ vector3s.Length ];
Array.Copy( vector3s, tmpLoopSpline, vector3s.Length );
tmpLoopSpline[ 0 ] = tmpLoopSpline[ tmpLoopSpline.Length - 3 ];
tmpLoopSpline[ tmpLoopSpline.Length - 1 ] = tmpLoopSpline[ 2 ];
vector3s = new Vector3[ tmpLoopSpline.Length ];
Array.Copy( tmpLoopSpline, vector3s, tmpLoopSpline.Length );
}
return ( vector3s );
}
return .5f * (
( -a + 3f * b - 3f * c + d ) * ( u * u * u )
+ ( 2f * a - 5f * b + 4f * c - d ) * ( u * u )
+ ( -a + c ) * u
+ 2f * b
);
}
tweens.Insert( 0, args );
target.AddComponent<iTween>();
}
//cast any accidentally supplied doubles and ints as floats as iTween only
uses floats internally and unify parameter case:
static Hashtable CleanArgs( Hashtable args ) {
Hashtable argsCopy = new Hashtable( args.Count );
Hashtable argsCaseUnified = new Hashtable( args.Count );
//random ID generator:
static string GenerateID() {
// int strlen = 15;
// char[] chars =
{'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u
','v','w','x','y','z','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','
P','Q','R','S','T','U','V','W','X','Y','Z','0','1','2','3','4','5','6','7','8'};
// int num_chars = chars.Length - 1;
// string randomChar = "";
// for (int i = 0; i < strlen; i++) {
// randomChar +=
chars[(int)Mathf.Floor(UnityEngine.Random.Range(0,num_chars))];
// }
return System.Guid.NewGuid().ToString();
}
id = (string)tweenArguments[ "id" ];
type = (string)tweenArguments[ "type" ];
/* GFX47 MOD START */
_name = (string)tweenArguments[ "name" ];
/* GFX47 MOD END */
method = (string)tweenArguments[ "method" ];
if ( tweenArguments.Contains( "time" ) ) {
time = (float)tweenArguments[ "time" ];
} else {
time = Defaults.time;
}
if ( tweenArguments.Contains( "delay" ) ) {
delay = (float)tweenArguments[ "delay" ];
} else {
delay = Defaults.delay;
}
if ( tweenArguments.Contains( "namedcolorvalue" ) ) {
//allows namedcolorvalue to be set as either an enum(C# friendly)
or a string(JS friendly), string case usage doesn't matter to further increase
usability:
if ( tweenArguments[ "namedcolorvalue" ].GetType() ==
typeof( NamedValueColor ) ) {
namedcolorvalue =
(NamedValueColor)tweenArguments[ "namedcolorvalue" ];
} else {
try {
namedcolorvalue =
(NamedValueColor)Enum.Parse( typeof( NamedValueColor ),
(string)tweenArguments[ "namedcolorvalue" ], true );
} catch {
Debug.LogWarning( "iTween: Unsupported
namedcolorvalue supplied! Default will be used." );
namedcolorvalue = iTween.NamedValueColor._Color;
}
}
} else {
namedcolorvalue = Defaults.namedColorValue;
}
if ( tweenArguments.Contains( "looptype" ) ) {
//allows loopType to be set as either an enum(C# friendly) or a
string(JS friendly), string case usage doesn't matter to further increase
usability:
if ( tweenArguments[ "looptype" ].GetType() == typeof( LoopType )
) {
loopType = (LoopType)tweenArguments[ "looptype" ];
} else {
try {
loopType = (LoopType)Enum.Parse( typeof( LoopType ),
(string)tweenArguments[ "looptype" ], true );
} catch {
Debug.LogWarning( "iTween: Unsupported loopType
supplied! Default will be used." );
loopType = iTween.LoopType.none;
}
}
} else {
loopType = iTween.LoopType.none;
}
if ( tweenArguments.Contains( "easetype" ) ) {
//allows easeType to be set as either an enum(C# friendly) or a
string(JS friendly), string case usage doesn't matter to further increase
usability:
if ( tweenArguments[ "easetype" ].GetType() == typeof( EaseType )
) {
easeType = (EaseType)tweenArguments[ "easetype" ];
} else {
try {
easeType = (EaseType)Enum.Parse( typeof( EaseType ),
(string)tweenArguments[ "easetype" ], true );
} catch {
Debug.LogWarning( "iTween: Unsupported easeType
supplied! Default will be used." );
easeType = Defaults.easeType;
}
}
} else {
easeType = Defaults.easeType;
}
if ( tweenArguments.Contains( "space" ) ) {
//allows space to be set as either an enum(C# friendly) or a
string(JS friendly), string case usage doesn't matter to further increase
usability:
if ( tweenArguments[ "space" ].GetType() == typeof( Space ) ) {
space = (Space)tweenArguments[ "space" ];
} else {
try {
space = (Space)Enum.Parse( typeof( Space ),
(string)tweenArguments[ "space" ], true );
} catch {
Debug.LogWarning( "iTween: Unsupported space
supplied! Default will be used." );
space = Defaults.space;
}
}
} else {
space = Defaults.space;
}
if ( tweenArguments.Contains( "islocal" ) ) {
isLocal = (bool)tweenArguments[ "islocal" ];
} else {
isLocal = Defaults.isLocal;
}
// Added by PressPlay
if ( tweenArguments.Contains( "ignoretimescale" ) ) {
useRealTime = (bool)tweenArguments[ "ignoretimescale" ];
} else {
useRealTime = Defaults.useRealTime;
}
// Added by PressPlay
if ( useRealTime ) {
runningTime += ( Time.realtimeSinceStartup - lastRealTime );
} else {
runningTime += Time.deltaTime;
}
if ( reverse ) {
percentage = 1 - runningTime / time;
} else {
percentage = runningTime / time;
}
void Dispose() {
for ( int i = 0; i < tweens.Count; i++ ) {
Hashtable tweenEntry = tweens[ i ];
if ( (string)tweenEntry[ "id" ] == id ) {
tweens.RemoveAt( i );
break;
}
}
Destroy( this );
}
void ConflictCheck() {//if a new iTween is about to run and is of the same
type as an in progress iTween this will destroy the previous if the new one is NOT
identical in every way or it will destroy the new iTween if they are:
Component[] tweens = GetComponents<iTween>();
foreach ( iTween item in tweens ) {
if ( item.type == "value" ) {
return;
} else if ( item.isRunning && item.type == type ) {
//cancel out if this is a shake or punch variant:
if ( item.method != method ) {
return;
}
void EnableKinematic() {
/*
if(gameObject.GetComponent(typeof(Rigidbody))){
if(!rigidbody.isKinematic){
kinematic=true;
rigidbody.isKinematic=true;
}
}
*/
}
void DisableKinematic() {
/*
if(kinematic && rigidbody.isKinematic==true){
kinematic=false;
rigidbody.isKinematic=false;
}
*/
}
void ResumeDelay() {
StartCoroutine( "TweenDelay" );
}
#endregion
float d = 1f;
float p = d * .3f;
float s = 0;
float a = 0;
float d = 1f;
float p = d * .3f;
float s = 0;
float a = 0;
float d = 1f;
float p = d * .3f;
float s = 0;
float a = 0;
#endregion