ITweenX

From Unify Community Wiki
(Difference between revisions)
Jump to: navigation, search
(Replaced the switch by an array, added some parameters.)
m (C# - iTweenX.cs)
Line 38: Line 38:
 
<syntaxhighlight lang="csharp">public enum EaseType
 
<syntaxhighlight lang="csharp">public enum EaseType
 
{
 
{
EaseInQuad,
+
EaseInQuad = 0,
 
EaseOutQuad,     
 
EaseOutQuad,     
 
EaseInOutQuad,   
 
EaseInOutQuad,   
Line 116: Line 116:
 
public const string to = "to";
 
public const string to = "to";
 
public const string onStart =          "onstart";
 
public const string onStart =          "onstart";
public const string onStarttarget = "onstarttarget";
+
public const string onStartTarget = "onstarttarget";
public const string onStartparams = "onstartparams";
+
public const string onStartParams = "onstartparams";
 
public const string onUpdate = "onupdate";
 
public const string onUpdate = "onupdate";
public const string onUpdatetarget = "onupdatetarget";
+
public const string onUpdateTarget = "onupdatetarget";
public const string onUpdateparams = "onupdateparams";
+
public const string onUpdateParams = "onupdateparams";
 
public const string onComplete = "oncomplete";
 
public const string onComplete = "oncomplete";
public const string onCompletetarget = "oncompletetarget";
+
public const string onCompleteTarget = "oncompletetarget";
public const string onCompleteparams = "oncompleteparams";
+
public const string onCompleteParams = "oncompleteparams";
 
public const string ignoreTimescale = "ignoretimescale";
 
public const string ignoreTimescale = "ignoretimescale";
 
public const string easeType = "easetype";
 
public const string easeType = "easetype";

Revision as of 10:03, 23 October 2012


Author: Berenger

Contents

Description

Bunch of variables to use with iTween instead of searching the keywords every times.

Usage

Put this script in your Standard Assets/Scripts folder; this way it can be easily used from javascript or Boo. If you declare a public var of type EaseType, you can easily pick the right easetype from the inspector.


Example

public class MyClass: MonoBehaviour
{
	public EaseType easeType;
 
	void Start()
	{
		iTween.ValueTo( gameObject, iTween.Hash( iTweenX.from, 0f, iTweenX.to, 1f, iTweenX.time, 1f,
                                                 iTweenX.onUpdate, "OnUpdateValue",
                                                 iTweenX.onStart, "OnStart",
                                                 iTweenX.onComplete, "OnComplete",
                                                 iTweenX.easeType, iTweenX.Ease(easeType),
                                                 iTweenX.ignoreTimescale, true ) );
	}
	void OnUpdateValue(float value){ print( "OnUpdateValue : " + value.ToString() ); }
	void OnStart(){ print( "OnStart" ); }
	void OnComplete(){ print( "OnComplete" ); }
}


C# - iTweenX.cs

public enum EaseType
{
	EaseInQuad = 0,
	EaseOutQuad,    
	EaseInOutQuad,  
	EaseInCubic,    
	EaseOutCubic,   
	EaseInOutCubic, 
	EaseInQuart,    
	EaseOutQuart,   
	EaseInOutQuart, 
	EaseInQuint,    
	EaseOutQuint,   
	EaseInOutQuint, 
	EaseInSine,     
	EaseOutSine,    
	EaseInOutSine,  
	EaseInExpo,     
	EaseOutExpo,    
	EaseInOutExpo,  
	EaseInCirc,     
	EaseOutCirc,    
	EaseInOutCirc,  
	Linear,         
	Spring,         
	EaseInBounce,   
	EaseOutBounce,  
	EaseInOutBounce,
	EaseInBack,     
	EaseOutBack,    
	EaseInOutBack,  
	EaseInElastic,  
	EaseOutElastic, 
	EaseInOutElastic
}
 
public static class iTweenX
{	
	public readonly static string[] easeTypes = new string[33]
	{
		"easeType",
		"easeInQuad",
		"easeOutQuad",
		"easeInOutQuad",
		"easeInCubic",
		"easeOutCubic",
		"easeInOutCubic",
		"easeInQuart",
		"easeOutQuart",
		"easeInOutQuart",
		"easeInQuint",
		"easeOutQuint",
		"easeInOutQuint",
		"easeInSine",
		"easeOutSine",
		"easeInOutSine",
		"easeInExpo",
		"easeOutExpo",
		"easeInOutExpo",
		"easeInCirc",
		"easeOutCirc",
		"easeInOutCirc",
		"linear",
		"spring",
		"easeInBounce",
		"easeOutBounce",
		"easeInOutBounce",
		"easeInBack",
		"easeOutBack",
		"easeInOutBack",
		"easeInElastic",
		"easeOutElastic",
		"easeInOutElastic"
	};
 
	public const string time =		"time";
	public const string speed =		"speed";
	public const string from =		"from";
	public const string to =		"to";
	public const string onStart =          	"onstart";
	public const string onStartTarget =	"onstarttarget";
	public const string onStartParams =	"onstartparams";
	public const string onUpdate =		"onupdate";
	public const string onUpdateTarget =	"onupdatetarget";
	public const string onUpdateParams =	"onupdateparams";
	public const string onComplete =	"oncomplete";
	public const string onCompleteTarget =	"oncompletetarget";
	public const string onCompleteParams =	"oncompleteparams";
	public const string ignoreTimescale =	"ignoretimescale";
	public const string easeType =		"easetype";
 
	public static string Ease( EaseType type )
	{
		return easeTypes[ (int)type ];
	}
}
Personal tools
Namespaces

Variants
Actions
Navigation
Extras
Toolbox