init
This commit is contained in:
commit
341a877b4a
2338 changed files with 1346408 additions and 0 deletions
2308
Assets/LeanTween/Framework/LTDescr.cs
Normal file
2308
Assets/LeanTween/Framework/LTDescr.cs
Normal file
File diff suppressed because it is too large
Load diff
12
Assets/LeanTween/Framework/LTDescr.cs.meta
Normal file
12
Assets/LeanTween/Framework/LTDescr.cs.meta
Normal file
|
@ -0,0 +1,12 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 381c8d6fb1acdc348870a7147bc98723
|
||||
timeCreated: 1463137984
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
89
Assets/LeanTween/Framework/LTDescrOptional.cs
Normal file
89
Assets/LeanTween/Framework/LTDescrOptional.cs
Normal file
|
@ -0,0 +1,89 @@
|
|||
//namespace DentedPixel{
|
||||
using UnityEngine;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class LTDescrOptional {
|
||||
|
||||
public Transform toTrans { get; set; }
|
||||
public Vector3 point { get; set; }
|
||||
public Vector3 axis { get; set; }
|
||||
public float lastVal{ get; set; }
|
||||
public Quaternion origRotation { get; set; }
|
||||
public LTBezierPath path { get; set; }
|
||||
public LTSpline spline { get; set; }
|
||||
public AnimationCurve animationCurve;
|
||||
public int initFrameCount;
|
||||
public Color color;
|
||||
|
||||
public LTRect ltRect { get; set; } // maybe get rid of this eventually
|
||||
|
||||
public Action<float> onUpdateFloat { get; set; }
|
||||
public Action<float,float> onUpdateFloatRatio { get; set; }
|
||||
public Action<float,object> onUpdateFloatObject { get; set; }
|
||||
public Action<Vector2> onUpdateVector2 { get; set; }
|
||||
public Action<Vector3> onUpdateVector3 { get; set; }
|
||||
public Action<Vector3,object> onUpdateVector3Object { get; set; }
|
||||
public Action<Color> onUpdateColor { get; set; }
|
||||
public Action<Color,object> onUpdateColorObject { get; set; }
|
||||
public Action onComplete { get; set; }
|
||||
public Action<object> onCompleteObject { get; set; }
|
||||
public object onCompleteParam { get; set; }
|
||||
public object onUpdateParam { get; set; }
|
||||
public Action onStart { get; set; }
|
||||
|
||||
|
||||
// #if !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2
|
||||
// public SpriteRenderer spriteRen { get; set; }
|
||||
// #endif
|
||||
//
|
||||
// #if LEANTWEEN_1
|
||||
// public Hashtable optional;
|
||||
// #endif
|
||||
// #if !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2 && !UNITY_4_3 && !UNITY_4_5
|
||||
// public RectTransform rectTransform;
|
||||
// public UnityEngine.UI.Text uiText;
|
||||
// public UnityEngine.UI.Image uiImage;
|
||||
// public UnityEngine.Sprite[] sprites;
|
||||
// #endif
|
||||
|
||||
|
||||
public void reset(){
|
||||
animationCurve = null;
|
||||
|
||||
this.onUpdateFloat = null;
|
||||
this.onUpdateFloatRatio = null;
|
||||
this.onUpdateVector2 = null;
|
||||
this.onUpdateVector3 = null;
|
||||
this.onUpdateFloatObject = null;
|
||||
this.onUpdateVector3Object = null;
|
||||
this.onUpdateColor = null;
|
||||
this.onComplete = null;
|
||||
this.onCompleteObject = null;
|
||||
this.onCompleteParam = null;
|
||||
this.onStart = null;
|
||||
|
||||
this.point = Vector3.zero;
|
||||
this.initFrameCount = 0;
|
||||
}
|
||||
|
||||
public void callOnUpdate( float val, float ratioPassed){
|
||||
if(this.onUpdateFloat!=null)
|
||||
this.onUpdateFloat(val);
|
||||
|
||||
if (this.onUpdateFloatRatio != null){
|
||||
this.onUpdateFloatRatio(val,ratioPassed);
|
||||
}else if(this.onUpdateFloatObject!=null){
|
||||
this.onUpdateFloatObject(val, this.onUpdateParam);
|
||||
}else if(this.onUpdateVector3Object!=null){
|
||||
this.onUpdateVector3Object(LTDescr.newVect, this.onUpdateParam);
|
||||
}else if(this.onUpdateVector3!=null){
|
||||
this.onUpdateVector3(LTDescr.newVect);
|
||||
}else if(this.onUpdateVector2!=null){
|
||||
this.onUpdateVector2(new Vector2(LTDescr.newVect.x,LTDescr.newVect.y));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//}
|
12
Assets/LeanTween/Framework/LTDescrOptional.cs.meta
Normal file
12
Assets/LeanTween/Framework/LTDescrOptional.cs.meta
Normal file
|
@ -0,0 +1,12 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c1ba8f1ef97134cb39b52ae26678db63
|
||||
timeCreated: 1471504769
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
225
Assets/LeanTween/Framework/LTSeq.cs
Normal file
225
Assets/LeanTween/Framework/LTSeq.cs
Normal file
|
@ -0,0 +1,225 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/**
|
||||
* Internal Representation of a Sequence<br>
|
||||
* <br>
|
||||
* <h4>Example:</h4>
|
||||
* var seq = LeanTween.sequence();<br>
|
||||
* seq.append(1f); <span style="color:gray">// delay everything one second</span><br>
|
||||
* seq.append( () => { <span style="color:gray">// fire an event before start</span><br>
|
||||
* Debug.Log("I have started");<br>
|
||||
* });<br>
|
||||
* seq.append( LeanTween.move(cube1, Vector3.one * 10f, 1f) ); <span style="color:gray">// do a tween</span><br>
|
||||
* seq.append( (object obj) => { <span style="color:gray">// fire event after tween</span><br>
|
||||
* var dict = obj as Dictionary<string,string>;<br>
|
||||
* Debug.Log("We are done now obj value:"+dict["hi"]);<br>
|
||||
* }, new Dictionary<string,string>(){ {"hi","sup"} } );<br>
|
||||
* @class LTSeq
|
||||
* @constructor
|
||||
*/
|
||||
public class LTSeq {
|
||||
|
||||
public LTSeq previous;
|
||||
|
||||
public LTSeq current;
|
||||
|
||||
public LTDescr tween;
|
||||
|
||||
public float totalDelay;
|
||||
|
||||
public float timeScale;
|
||||
|
||||
private int debugIter;
|
||||
|
||||
public uint counter;
|
||||
|
||||
public bool toggle = false;
|
||||
|
||||
private uint _id;
|
||||
|
||||
public int id{
|
||||
get{
|
||||
uint toId = _id | counter << 16;
|
||||
|
||||
/*uint backId = toId & 0xFFFF;
|
||||
uint backCounter = toId >> 16;
|
||||
if(_id!=backId || backCounter!=counter){
|
||||
Debug.LogError("BAD CONVERSION toId:"+_id);
|
||||
}*/
|
||||
|
||||
return (int)toId;
|
||||
}
|
||||
}
|
||||
|
||||
public void reset(){
|
||||
previous = null;
|
||||
tween = null;
|
||||
totalDelay = 0f;
|
||||
}
|
||||
|
||||
public void init(uint id, uint global_counter){
|
||||
reset();
|
||||
_id = id;
|
||||
|
||||
counter = global_counter;
|
||||
|
||||
this.current = this;
|
||||
}
|
||||
|
||||
private LTSeq addOn(){
|
||||
this.current.toggle = true;
|
||||
LTSeq lastCurrent = this.current;
|
||||
this.current = LeanTween.sequence(true);
|
||||
// Debug.Log("this.current:" + this.current.id + " lastCurrent:" + lastCurrent.id);
|
||||
this.current.previous = lastCurrent;
|
||||
lastCurrent.toggle = false;
|
||||
this.current.totalDelay = lastCurrent.totalDelay;
|
||||
this.current.debugIter = lastCurrent.debugIter + 1;
|
||||
return current;
|
||||
}
|
||||
|
||||
private float addPreviousDelays(){
|
||||
// Debug.Log("delay:"+delay+" count:"+this.current.count+" this.current.totalDelay:"+this.current.totalDelay);
|
||||
|
||||
LTSeq prev = this.current.previous;
|
||||
|
||||
if (prev != null && prev.tween!=null) {
|
||||
return this.current.totalDelay + prev.tween.time;
|
||||
}
|
||||
return this.current.totalDelay;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a time delay to the sequence
|
||||
* @method append (delay)
|
||||
* @param {float} delay:float amount of time to add to the sequence
|
||||
* @return {LTSeq} LTDescr an object that distinguishes the tween
|
||||
* var seq = LeanTween.sequence();<br>
|
||||
* seq.append(1f); // delay everything one second<br>
|
||||
* seq.append( LeanTween.move(cube1, Vector3.one * 10f, 1f) ); // do a tween<br>
|
||||
*/
|
||||
public LTSeq append( float delay ){
|
||||
this.current.totalDelay += delay;
|
||||
|
||||
return this.current;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a time delay to the sequence
|
||||
* @method append (method)
|
||||
* @param {System.Action} callback:System.Action method you want to be called
|
||||
* @return {LTSeq} LTSeq an object that you can add tweens, methods and time on to
|
||||
* @example
|
||||
* var seq = LeanTween.sequence();<br>
|
||||
* seq.append( () => { // fire an event before start<br>
|
||||
* Debug.Log("I have started");<br>
|
||||
* });<br>
|
||||
* seq.append( LeanTween.move(cube1, Vector3.one * 10f, 1f) ); // do a tween<br>
|
||||
* seq.append( () => { // fire event after tween<br>
|
||||
* Debug.Log("We are done now");<br>
|
||||
* });;<br>
|
||||
*/
|
||||
public LTSeq append( System.Action callback ){
|
||||
LTDescr newTween = LeanTween.delayedCall(0f, callback);
|
||||
// Debug.Log("newTween:" + newTween);
|
||||
return append(newTween);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a time delay to the sequence
|
||||
* @method add (method(object))
|
||||
* @param {System.Action} callback:System.Action method you want to be called
|
||||
* @return {LTSeq} LTSeq an object that you can add tweens, methods and time on to
|
||||
* @example
|
||||
* var seq = LeanTween.sequence();<br>
|
||||
* seq.append( () => { // fire an event before start<br>
|
||||
* Debug.Log("I have started");<br>
|
||||
* });<br>
|
||||
* seq.append( LeanTween.move(cube1, Vector3.one * 10f, 1f) ); // do a tween<br>
|
||||
* seq.append((object obj) => { // fire event after tween
|
||||
* var dict = obj as Dictionary<string,string>;
|
||||
* Debug.Log("We are done now obj value:"+dict["hi"]);
|
||||
* }, new Dictionary<string,string>(){ {"hi","sup"} } );
|
||||
*/
|
||||
public LTSeq append( System.Action<object> callback, object obj ){
|
||||
append(LeanTween.delayedCall(0f, callback).setOnCompleteParam(obj));
|
||||
|
||||
return addOn();
|
||||
}
|
||||
|
||||
public LTSeq append( GameObject gameObject, System.Action callback ){
|
||||
append(LeanTween.delayedCall(gameObject, 0f, callback));
|
||||
|
||||
return addOn();
|
||||
}
|
||||
|
||||
public LTSeq append( GameObject gameObject, System.Action<object> callback, object obj ){
|
||||
append(LeanTween.delayedCall(gameObject, 0f, callback).setOnCompleteParam(obj));
|
||||
|
||||
return addOn();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a sequencer object where you can easily chain together tweens and methods one after another
|
||||
*
|
||||
* @method add (tween)
|
||||
* @return {LTSeq} LTSeq an object that you can add tweens, methods and time on to
|
||||
* @example
|
||||
* var seq = LeanTween.sequence();<br>
|
||||
* seq.append( LeanTween.move(cube1, Vector3.one * 10f, 1f) ); // do a move tween<br>
|
||||
* seq.append( LeanTween.rotateAround( avatar1, Vector3.forward, 360f, 1f ) ); // then do a rotate tween<br>
|
||||
*/
|
||||
public LTSeq append( LTDescr tween ){
|
||||
this.current.tween = tween;
|
||||
|
||||
// Debug.Log("tween:" + tween + " delay:" + this.current.totalDelay);
|
||||
|
||||
this.current.totalDelay = addPreviousDelays();
|
||||
|
||||
tween.setDelay( this.current.totalDelay );
|
||||
|
||||
return addOn();
|
||||
}
|
||||
|
||||
public LTSeq insert( LTDescr tween ){
|
||||
this.current.tween = tween;
|
||||
|
||||
tween.setDelay( addPreviousDelays() );
|
||||
|
||||
return addOn();
|
||||
}
|
||||
|
||||
|
||||
public LTSeq setScale( float timeScale ){
|
||||
// Debug.Log("this.current:" + this.current.previous.debugIter+" tween:"+this.current.previous.tween);
|
||||
setScaleRecursive(this.current, timeScale, 500);
|
||||
|
||||
return addOn();
|
||||
}
|
||||
|
||||
private void setScaleRecursive( LTSeq seq, float timeScale, int count ){
|
||||
if (count > 0) {
|
||||
this.timeScale = timeScale;
|
||||
|
||||
// Debug.Log("seq.count:" + count + " seq.tween:" + seq.tween);
|
||||
seq.totalDelay *= timeScale;
|
||||
if (seq.tween != null) {
|
||||
// Debug.Log("seq.tween.time * timeScale:" + seq.tween.time * timeScale + " seq.totalDelay:"+seq.totalDelay +" time:"+seq.tween.time+" seq.tween.delay:"+seq.tween.delay);
|
||||
if (seq.tween.time != 0f)
|
||||
seq.tween.setTime(seq.tween.time * timeScale);
|
||||
seq.tween.setDelay(seq.tween.delay * timeScale);
|
||||
}
|
||||
|
||||
if (seq.previous != null)
|
||||
setScaleRecursive(seq.previous, timeScale, count - 1);
|
||||
}
|
||||
}
|
||||
|
||||
public LTSeq reverse(){
|
||||
|
||||
return addOn();
|
||||
}
|
||||
|
||||
}
|
12
Assets/LeanTween/Framework/LTSeq.cs.meta
Normal file
12
Assets/LeanTween/Framework/LTSeq.cs.meta
Normal file
|
@ -0,0 +1,12 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 6c88dbe4cdd9944f198e9796ee394c86
|
||||
timeCreated: 1488665079
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
418
Assets/LeanTween/Framework/LeanAudio.cs
Normal file
418
Assets/LeanTween/Framework/LeanAudio.cs
Normal file
|
@ -0,0 +1,418 @@
|
|||
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class LeanAudioStream {
|
||||
|
||||
public int position = 0;
|
||||
|
||||
public AudioClip audioClip;
|
||||
public float[] audioArr;
|
||||
|
||||
public LeanAudioStream( float[] audioArr ){
|
||||
this.audioArr = audioArr;
|
||||
}
|
||||
|
||||
public void OnAudioRead(float[] data) {
|
||||
int count = 0;
|
||||
while (count < data.Length) {
|
||||
data[count] = audioArr[this.position];
|
||||
position++;
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
public void OnAudioSetPosition(int newPosition) {
|
||||
this.position = newPosition;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Audio dynamically and easily playback
|
||||
*
|
||||
* @class LeanAudio
|
||||
* @constructor
|
||||
*/
|
||||
public class LeanAudio : object {
|
||||
|
||||
public static float MIN_FREQEUNCY_PERIOD = 0.000115f;
|
||||
public static int PROCESSING_ITERATIONS_MAX = 50000;
|
||||
public static float[] generatedWaveDistances;
|
||||
public static int generatedWaveDistancesCount = 0;
|
||||
|
||||
private static float[] longList;
|
||||
|
||||
public static LeanAudioOptions options(){
|
||||
if(generatedWaveDistances==null){
|
||||
generatedWaveDistances = new float[ PROCESSING_ITERATIONS_MAX ];
|
||||
longList = new float[ PROCESSING_ITERATIONS_MAX ];
|
||||
}
|
||||
return new LeanAudioOptions();
|
||||
}
|
||||
|
||||
public static LeanAudioStream createAudioStream( AnimationCurve volume, AnimationCurve frequency, LeanAudioOptions options = null ){
|
||||
if(options==null)
|
||||
options = new LeanAudioOptions();
|
||||
|
||||
options.useSetData = false;
|
||||
|
||||
int generatedWavePtsLength = createAudioWave( volume, frequency, options);
|
||||
createAudioFromWave( generatedWavePtsLength, options );
|
||||
|
||||
return options.stream;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create dynamic audio from a set of Animation Curves and other options.
|
||||
*
|
||||
* @method createAudio
|
||||
* @param {AnimationCurve} volumeCurve:AnimationCurve describing the shape of the audios volume (from 0-1). The length of the audio is dicated by the end value here.
|
||||
* @param {AnimationCurve} frequencyCurve:AnimationCurve describing the width of the oscillations between the sound waves in seconds. Large numbers mean a lower note, while higher numbers mean a tighter frequency and therefor a higher note. Values are usually between 0.01 and 0.000001 (or smaller)
|
||||
* @param {LeanAudioOptions} options:LeanAudioOptions You can pass any other values in here like vibrato or the frequency you would like the sound to be encoded at. See <a href="LeanAudioOptions.html">LeanAudioOptions</a> for more details.
|
||||
* @return {AudioClip} AudioClip of the procedurally generated audio
|
||||
* @example
|
||||
* AnimationCurve volumeCurve = new AnimationCurve( new Keyframe(0f, 1f, 0f, -1f), new Keyframe(1f, 0f, -1f, 0f));<br>
|
||||
* AnimationCurve frequencyCurve = new AnimationCurve( new Keyframe(0f, 0.003f, 0f, 0f), new Keyframe(1f, 0.003f, 0f, 0f));<br>
|
||||
* AudioClip audioClip = LeanAudio.createAudio(volumeCurve, frequencyCurve, LeanAudio.options().setVibrato( new Vector3[]{ new Vector3(0.32f,0f,0f)} ));<br>
|
||||
*/
|
||||
public static AudioClip createAudio( AnimationCurve volume, AnimationCurve frequency, LeanAudioOptions options = null ){
|
||||
if(options==null)
|
||||
options = new LeanAudioOptions();
|
||||
|
||||
int generatedWavePtsLength = createAudioWave( volume, frequency, options);
|
||||
// Debug.Log("generatedWavePtsLength:"+generatedWavePtsLength);
|
||||
return createAudioFromWave( generatedWavePtsLength, options );
|
||||
}
|
||||
|
||||
private static int createAudioWave( AnimationCurve volume, AnimationCurve frequency, LeanAudioOptions options ){
|
||||
float time = volume[ volume.length - 1 ].time;
|
||||
int listLength = 0;
|
||||
// List<float> list = new List<float>();
|
||||
|
||||
// generatedWaveDistances = new List<float>();
|
||||
// float[] vibratoValues = new float[ vibrato.Length ];
|
||||
float passed = 0f;
|
||||
for(int i = 0; i < PROCESSING_ITERATIONS_MAX; i++){
|
||||
float f = frequency.Evaluate(passed);
|
||||
if(f<MIN_FREQEUNCY_PERIOD)
|
||||
f = MIN_FREQEUNCY_PERIOD;
|
||||
float height = volume.Evaluate(passed + 0.5f*f);
|
||||
if(options.vibrato!=null){
|
||||
for(int j=0; j<options.vibrato.Length; j++){
|
||||
float peakMulti = Mathf.Abs( Mathf.Sin( 1.5708f + passed * (1f/options.vibrato[j][0]) * Mathf.PI ) );
|
||||
float diff = (1f-options.vibrato[j][1]);
|
||||
peakMulti = options.vibrato[j][1] + diff*peakMulti;
|
||||
height *= peakMulti;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Debug.Log("i:"+i+" f:"+f+" passed:"+passed+" height:"+height+" time:"+time);
|
||||
if(passed + 0.5f*f>=time)
|
||||
break;
|
||||
if(listLength >= PROCESSING_ITERATIONS_MAX-1){
|
||||
Debug.LogError("LeanAudio has reached it's processing cap. To avoid this error increase the number of iterations ex: LeanAudio.PROCESSING_ITERATIONS_MAX = "+(PROCESSING_ITERATIONS_MAX*2));
|
||||
break;
|
||||
}else{
|
||||
int distPoint = listLength / 2;
|
||||
|
||||
//generatedWaveDistances.Add( f );
|
||||
passed += f;
|
||||
|
||||
generatedWaveDistances[ distPoint ] = passed;
|
||||
//Debug.Log("distPoint:"+distPoint+" passed:"+passed);
|
||||
|
||||
//list.Add( passed );
|
||||
//list.Add( i%2==0 ? -height : height );
|
||||
|
||||
longList[ listLength ] = passed;
|
||||
longList[ listLength + 1 ] = i%2==0 ? -height : height;
|
||||
}
|
||||
|
||||
|
||||
|
||||
listLength += 2;
|
||||
|
||||
}
|
||||
|
||||
listLength += -2;
|
||||
generatedWaveDistancesCount = listLength / 2;
|
||||
|
||||
/*float[] wave = new float[ listLength ];
|
||||
for(int i = 0; i < wave.Length; i++){
|
||||
wave[i] = longList[i];
|
||||
}*/
|
||||
return listLength;
|
||||
}
|
||||
|
||||
private static AudioClip createAudioFromWave( int waveLength, LeanAudioOptions options ){
|
||||
float time = longList[ waveLength - 2 ];
|
||||
float[] audioArr = new float[ (int)(options.frequencyRate*time) ];
|
||||
|
||||
int waveIter = 0;
|
||||
float subWaveDiff = longList[waveIter];
|
||||
float subWaveTimeLast = 0f;
|
||||
float subWaveTime = longList[waveIter];
|
||||
float waveHeight = longList[waveIter+1];
|
||||
for(int i = 0; i < audioArr.Length; i++){
|
||||
float passedTime = (float)i / (float)options.frequencyRate;
|
||||
if(passedTime > longList[waveIter] ){
|
||||
subWaveTimeLast = longList[waveIter];
|
||||
waveIter += 2;
|
||||
subWaveDiff = longList[waveIter] - longList[waveIter-2];
|
||||
waveHeight = longList[waveIter+1];
|
||||
// Debug.Log("passed wave i:"+i);
|
||||
}
|
||||
subWaveTime = passedTime - subWaveTimeLast;
|
||||
float ratioElapsed = subWaveTime / subWaveDiff;
|
||||
|
||||
float value = Mathf.Sin( ratioElapsed * Mathf.PI );
|
||||
|
||||
if(options.waveStyle==LeanAudioOptions.LeanAudioWaveStyle.Square){
|
||||
if(value>0f)
|
||||
value = 1f;
|
||||
if(value<0f)
|
||||
value = -1f;
|
||||
}else if(options.waveStyle==LeanAudioOptions.LeanAudioWaveStyle.Sawtooth){
|
||||
float sign = value > 0f ? 1f : -1f;
|
||||
if(ratioElapsed<0.5f){
|
||||
value = (ratioElapsed*2f)*sign;
|
||||
}else{ // 0.5f - 1f
|
||||
value = (1f - ratioElapsed)*2f*sign;
|
||||
}
|
||||
}else if(options.waveStyle==LeanAudioOptions.LeanAudioWaveStyle.Noise){
|
||||
float peakMulti = (1f-options.waveNoiseInfluence) + Mathf.PerlinNoise(0f, passedTime * options.waveNoiseScale ) * options.waveNoiseInfluence;
|
||||
|
||||
/*if(i<25){
|
||||
Debug.Log("passedTime:"+passedTime+" peakMulti:"+peakMulti+" infl:"+options.waveNoiseInfluence);
|
||||
}*/
|
||||
|
||||
value *= peakMulti;
|
||||
}
|
||||
|
||||
//if(i<25)
|
||||
// Debug.Log("passedTime:"+passedTime+" value:"+value+" ratioElapsed:"+ratioElapsed+" subWaveTime:"+subWaveTime+" subWaveDiff:"+subWaveDiff);
|
||||
|
||||
value *= waveHeight;
|
||||
|
||||
|
||||
if(options.modulation!=null){
|
||||
for(int k=0; k<options.modulation.Length; k++){
|
||||
float peakMulti = Mathf.Abs( Mathf.Sin( 1.5708f + passedTime * (1f/options.modulation[k][0]) * Mathf.PI ) );
|
||||
float diff = (1f-options.modulation[k][1]);
|
||||
peakMulti = options.modulation[k][1] + diff*peakMulti;
|
||||
// if(k<10){
|
||||
// Debug.Log("k:"+k+" peakMulti:"+peakMulti+" value:"+value+" after:"+(value*peakMulti));
|
||||
// }
|
||||
value *= peakMulti;
|
||||
}
|
||||
}
|
||||
|
||||
audioArr[i] = value;
|
||||
// Debug.Log("pt:"+pt+" i:"+i+" val:"+audioArr[i]+" len:"+audioArr.Length);
|
||||
}
|
||||
|
||||
|
||||
int lengthSamples = audioArr.Length;
|
||||
|
||||
#if UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_5 || UNITY_4_6 || UNITY_4_7
|
||||
bool is3dSound = false;
|
||||
AudioClip audioClip = AudioClip.Create("Generated Audio", lengthSamples, 1, options.frequencyRate, is3dSound, false);
|
||||
#else
|
||||
AudioClip audioClip = null;
|
||||
if(options.useSetData){
|
||||
audioClip = AudioClip.Create("Generated Audio", lengthSamples, 1, options.frequencyRate, false, null, OnAudioSetPosition);
|
||||
audioClip.SetData(audioArr, 0);
|
||||
}else{
|
||||
options.stream = new LeanAudioStream(audioArr);
|
||||
// Debug.Log("len:"+audioArr.Length+" lengthSamples:"+lengthSamples+" freqRate:"+options.frequencyRate);
|
||||
audioClip = AudioClip.Create("Generated Audio", lengthSamples, 1, options.frequencyRate, false, options.stream.OnAudioRead, options.stream.OnAudioSetPosition);
|
||||
options.stream.audioClip = audioClip;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
return audioClip;
|
||||
}
|
||||
|
||||
private static void OnAudioSetPosition(int newPosition) {
|
||||
|
||||
}
|
||||
|
||||
public static AudioClip generateAudioFromCurve( AnimationCurve curve, int frequencyRate = 44100 ){
|
||||
float curveTime = curve[ curve.length - 1 ].time;
|
||||
float time = curveTime;
|
||||
float[] audioArr = new float[ (int)(frequencyRate*time) ];
|
||||
|
||||
// Debug.Log("curveTime:"+curveTime+" AudioSettings.outputSampleRate:"+AudioSettings.outputSampleRate);
|
||||
for(int i = 0; i < audioArr.Length; i++){
|
||||
float pt = (float)i / (float)frequencyRate;
|
||||
audioArr[i] = curve.Evaluate( pt );
|
||||
// Debug.Log("pt:"+pt+" i:"+i+" val:"+audioArr[i]+" len:"+audioArr.Length);
|
||||
}
|
||||
|
||||
int lengthSamples = audioArr.Length;//(int)( (float)frequencyRate * curveTime );
|
||||
#if UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_5 || UNITY_4_6 || UNITY_4_7
|
||||
bool is3dSound = false;
|
||||
AudioClip audioClip = AudioClip.Create("Generated Audio", lengthSamples, 1, frequencyRate, is3dSound, false);
|
||||
#else
|
||||
AudioClip audioClip = AudioClip.Create("Generated Audio", lengthSamples, 1, frequencyRate, false);
|
||||
#endif
|
||||
audioClip.SetData(audioArr, 0);
|
||||
|
||||
return audioClip;
|
||||
}
|
||||
|
||||
public static AudioSource play( AudioClip audio, float volume ){
|
||||
AudioSource audioSource = playClipAt(audio, Vector3.zero);
|
||||
audioSource.volume = volume;
|
||||
return audioSource;
|
||||
}
|
||||
|
||||
public static AudioSource play( AudioClip audio ){
|
||||
return playClipAt( audio, Vector3.zero );
|
||||
}
|
||||
|
||||
public static AudioSource play( AudioClip audio, Vector3 pos ){
|
||||
return playClipAt( audio, pos );
|
||||
}
|
||||
|
||||
public static AudioSource play( AudioClip audio, Vector3 pos, float volume ){
|
||||
// Debug.Log("audio length:"+audio.length);
|
||||
AudioSource audioSource = playClipAt(audio, pos);
|
||||
audioSource.minDistance = 1f;
|
||||
//audioSource.pitch = pitch;
|
||||
audioSource.volume = volume;
|
||||
|
||||
return audioSource;
|
||||
}
|
||||
|
||||
public static AudioSource playClipAt( AudioClip clip, Vector3 pos ) {
|
||||
GameObject tempGO = new GameObject(); // create the temp object
|
||||
tempGO.transform.position = pos; // set its position
|
||||
AudioSource aSource = tempGO.AddComponent<AudioSource>(); // add an audio source
|
||||
aSource.clip = clip; // define the clip
|
||||
aSource.Play(); // start the sound
|
||||
GameObject.Destroy(tempGO, clip.length); // destroy object after clip duration
|
||||
return aSource; // return the AudioSource reference
|
||||
}
|
||||
|
||||
public static void printOutAudioClip( AudioClip audioClip, ref AnimationCurve curve, float scaleX = 1f ){
|
||||
// Debug.Log("Audio channels:"+audioClip.channels+" frequency:"+audioClip.frequency+" length:"+audioClip.length+" samples:"+audioClip.samples);
|
||||
float[] samples = new float[audioClip.samples * audioClip.channels];
|
||||
audioClip.GetData(samples, 0);
|
||||
int i = 0;
|
||||
|
||||
Keyframe[] frames = new Keyframe[samples.Length];
|
||||
while (i < samples.Length) {
|
||||
frames[i] = new Keyframe( (float)i * scaleX, samples[i] );
|
||||
++i;
|
||||
}
|
||||
curve = new AnimationCurve( frames );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Pass in options to LeanAudio
|
||||
*
|
||||
* @class LeanAudioOptions
|
||||
* @constructor
|
||||
*/
|
||||
public class LeanAudioOptions : object {
|
||||
|
||||
public enum LeanAudioWaveStyle{
|
||||
Sine,
|
||||
Square,
|
||||
Sawtooth,
|
||||
Noise
|
||||
}
|
||||
|
||||
public LeanAudioWaveStyle waveStyle = LeanAudioWaveStyle.Sine;
|
||||
public Vector3[] vibrato;
|
||||
public Vector3[] modulation;
|
||||
public int frequencyRate = 44100;
|
||||
public float waveNoiseScale = 1000;
|
||||
public float waveNoiseInfluence = 1f;
|
||||
|
||||
public bool useSetData = true;
|
||||
public LeanAudioStream stream;
|
||||
|
||||
public LeanAudioOptions(){}
|
||||
|
||||
/**
|
||||
* Set the frequency for the audio is encoded. 44100 is CD quality, but you can usually get away with much lower (or use a lower amount to get a more 8-bit sound).
|
||||
*
|
||||
* @method setFrequency
|
||||
* @param {int} frequencyRate:int of the frequency you wish to encode the AudioClip at
|
||||
* @return {LeanAudioOptions} LeanAudioOptions describing optional values
|
||||
* @example
|
||||
* AnimationCurve volumeCurve = new AnimationCurve( new Keyframe(0f, 1f, 0f, -1f), new Keyframe(1f, 0f, -1f, 0f));<br>
|
||||
* AnimationCurve frequencyCurve = new AnimationCurve( new Keyframe(0f, 0.003f, 0f, 0f), new Keyframe(1f, 0.003f, 0f, 0f));<br>
|
||||
* AudioClip audioClip = LeanAudio.createAudio(volumeCurve, frequencyCurve, LeanAudio.options().setVibrato( new Vector3[]{ new Vector3(0.32f,0f,0f)} ).setFrequency(12100) );<br>
|
||||
*/
|
||||
public LeanAudioOptions setFrequency( int frequencyRate ){
|
||||
this.frequencyRate = frequencyRate;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set details about the shape of the curve by adding vibrato modulations through it (alters the peak values giving it a wah-wah effect). You can add as many as you want to sculpt out more detail in the sound wave.
|
||||
*
|
||||
* @method setVibrato
|
||||
* @param {Vector3[]} vibratoArray:Vector3[] The first value is the period in seconds that you wish to have the vibrato wave fluctuate at. The second value is the minimum height you wish the vibrato wave to dip down to (default is zero). The third is reserved for future effects.
|
||||
* @return {LeanAudioOptions} LeanAudioOptions describing optional values
|
||||
* @example
|
||||
* AnimationCurve volumeCurve = new AnimationCurve( new Keyframe(0f, 1f, 0f, -1f), new Keyframe(1f, 0f, -1f, 0f));<br>
|
||||
* AnimationCurve frequencyCurve = new AnimationCurve( new Keyframe(0f, 0.003f, 0f, 0f), new Keyframe(1f, 0.003f, 0f, 0f));<br>
|
||||
* AudioClip audioClip = LeanAudio.createAudio(volumeCurve, frequencyCurve, LeanAudio.options().setVibrato( new Vector3[]{ new Vector3(0.32f,0.3f,0f)} ).setFrequency(12100) );<br>
|
||||
*/
|
||||
public LeanAudioOptions setVibrato( Vector3[] vibrato ){
|
||||
this.vibrato = vibrato;
|
||||
return this;
|
||||
}
|
||||
|
||||
/*
|
||||
public LeanAudioOptions setModulation( Vector3[] modulation ){
|
||||
this.modulation = modulation;
|
||||
return this;
|
||||
}*/
|
||||
|
||||
public LeanAudioOptions setWaveSine(){
|
||||
this.waveStyle = LeanAudioWaveStyle.Sine;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LeanAudioOptions setWaveSquare(){
|
||||
this.waveStyle = LeanAudioWaveStyle.Square;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LeanAudioOptions setWaveSawtooth(){
|
||||
this.waveStyle = LeanAudioWaveStyle.Sawtooth;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LeanAudioOptions setWaveNoise(){
|
||||
this.waveStyle = LeanAudioWaveStyle.Noise;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LeanAudioOptions setWaveStyle( LeanAudioWaveStyle style ){
|
||||
this.waveStyle = style;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public LeanAudioOptions setWaveNoiseScale( float waveScale ){
|
||||
this.waveNoiseScale = waveScale;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LeanAudioOptions setWaveNoiseInfluence( float influence ){
|
||||
this.waveNoiseInfluence = influence;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
|
12
Assets/LeanTween/Framework/LeanAudio.cs.meta
Normal file
12
Assets/LeanTween/Framework/LeanAudio.cs.meta
Normal file
|
@ -0,0 +1,12 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 52e41e970d9353942b27458440bec9eb
|
||||
timeCreated: 1427917971
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
364
Assets/LeanTween/Framework/LeanSmooth.cs
Normal file
364
Assets/LeanTween/Framework/LeanSmooth.cs
Normal file
|
@ -0,0 +1,364 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/**
|
||||
* Use these smooth methods to move one value towards another<br /><br />
|
||||
* <strong>Example: </strong><br />fromY = LeanSmooth.spring(fromY, followArrow.localPosition.y, ref velocityY, 1.1f);<br />
|
||||
* fromVec3 = LeanSmooth.damp(fromVec3, dude5Title.localPosition, ref velocityVec3, 1.1f);<br />
|
||||
* fromColor = LeanSmooth.damp(fromColor, dude5Title.GetComponent<Renderer>().material.color, ref velocityColor, 1.1f);<br />
|
||||
* Debug.Log("Smoothed y:" + fromY + " vec3:" + fromVec3 + " color:" + fromColor);<br />
|
||||
*
|
||||
* @class LeanSmooth
|
||||
*/
|
||||
|
||||
public class LeanSmooth {
|
||||
|
||||
|
||||
/**
|
||||
* <summary>Moves one value towards another (eases in and out to destination with no overshoot)</summary>
|
||||
*
|
||||
* @method LeanSmooth.damp (float)
|
||||
* @param {float} current:float the current value
|
||||
* @param {float} target:float the value we are trying to reach
|
||||
* @param {float} currentVelocity:float the current velocity of the value
|
||||
* @param {float} smoothTime:float roughly the time it takes to reach the destination
|
||||
* @param {float} maxSpeed:float the top speed you want the value to move at (defaults to unlimited -1f)
|
||||
* @param {float} deltaTime:float the difference in time since the method was called (defaults to Time.deltaTime)
|
||||
* @example
|
||||
* followVar = LeanSmooth.damp(followVar, destinationVar, ref followVelocity, 1.1f);\n
|
||||
* Debug.Log("current:"+followVar);
|
||||
*/
|
||||
public static float damp(float current, float target, ref float currentVelocity, float smoothTime, float maxSpeed = -1f, float deltaTime = -1f)
|
||||
{
|
||||
if (deltaTime < 0f)
|
||||
deltaTime = Time.deltaTime;
|
||||
|
||||
smoothTime = Mathf.Max(0.0001f, smoothTime);
|
||||
float num = 2f / smoothTime;
|
||||
float num2 = num * deltaTime;
|
||||
float num3 = 1f / (1f + num2 + 0.48f * num2 * num2 + 0.235f * num2 * num2 * num2);
|
||||
float num4 = current - target;
|
||||
float num5 = target;
|
||||
if (maxSpeed > 0f)
|
||||
{
|
||||
float num6 = maxSpeed * smoothTime;
|
||||
num4 = Mathf.Clamp(num4, -num6, num6);
|
||||
}
|
||||
target = current - num4;
|
||||
float num7 = (currentVelocity + num * num4) * deltaTime;
|
||||
currentVelocity = (currentVelocity - num * num7) * num3;
|
||||
float num8 = target + (num4 + num7) * num3;
|
||||
if (num5 - current > 0f == num8 > num5)
|
||||
{
|
||||
num8 = num5;
|
||||
currentVelocity = (num8 - num5) / deltaTime;
|
||||
}
|
||||
return num8;
|
||||
}
|
||||
|
||||
/**
|
||||
* <summary>Moves one value towards another (eases in and out to destination with no overshoot)</summary>
|
||||
*
|
||||
* @method LeanSmooth.damp (Vector3)
|
||||
* @param {float} current:Vector3 the current value
|
||||
* @param {float} target:Vector3 the value we are trying to reach
|
||||
* @param {float} currentVelocity:Vector3 the current velocity of the value
|
||||
* @param {float} smoothTime:float roughly the time it takes to reach the destination
|
||||
* @param {float} maxSpeed:float the top speed you want the value to move at (defaults to unlimited -1f)
|
||||
* @param {float} deltaTime:float the difference in time since the method was called (defaults to Time.deltaTime)
|
||||
* @example
|
||||
* transform.position = LeanSmooth.damp(transform.position, destTrans.position, ref followVelocity, 1.1f);\n
|
||||
* Debug.Log("current:"+transform.position);
|
||||
*/
|
||||
public static Vector3 damp(Vector3 current, Vector3 target, ref Vector3 currentVelocity, float smoothTime, float maxSpeed = -1f, float deltaTime = -1f)
|
||||
{
|
||||
float x = damp(current.x, target.x, ref currentVelocity.x, smoothTime, maxSpeed, deltaTime);
|
||||
float y = damp(current.y, target.y, ref currentVelocity.y, smoothTime, maxSpeed, deltaTime);
|
||||
float z = damp(current.z, target.z, ref currentVelocity.z, smoothTime, maxSpeed, deltaTime);
|
||||
|
||||
return new Vector3(x, y, z);
|
||||
}
|
||||
|
||||
/**
|
||||
* <summary>Moves one color value towards another color (eases in and out to destination with no overshoot)</summary>
|
||||
*
|
||||
* @method LeanSmooth.damp (Color)
|
||||
* @param {float} current:Color the current value
|
||||
* @param {float} target:Color the value we are trying to reach
|
||||
* @param {float} currentVelocity:Color the current velocity of the value
|
||||
* @param {float} smoothTime:float roughly the time it takes to reach the destination
|
||||
* @param {float} maxSpeed:float the top speed you want the value to move at (defaults to unlimited -1f)
|
||||
* @param {float} deltaTime:float the difference in time since the method was called (defaults to Time.deltaTime)
|
||||
* @example
|
||||
* fromColor = LeanSmooth.damp(fromColor, transform.GetComponent<Renderer>().material.color, ref velocityColor, 1.1f);\n
|
||||
* Debug.Log("current:"+fromColor);
|
||||
*/
|
||||
public static Color damp(Color current, Color target, ref Color currentVelocity, float smoothTime, float maxSpeed = -1f, float deltaTime = -1f)
|
||||
{
|
||||
float r = damp(current.r, target.r, ref currentVelocity.r, smoothTime, maxSpeed, deltaTime);
|
||||
float g = damp(current.g, target.g, ref currentVelocity.g, smoothTime, maxSpeed, deltaTime);
|
||||
float b = damp(current.b, target.b, ref currentVelocity.b, smoothTime, maxSpeed, deltaTime);
|
||||
float a = damp(current.a, target.a, ref currentVelocity.a, smoothTime, maxSpeed, deltaTime);
|
||||
|
||||
return new Color(r, g, b, a);
|
||||
}
|
||||
|
||||
/**
|
||||
* <summary>Moves one value towards another (eases in and out to destination with possible overshoot bounciness)</summary>
|
||||
*
|
||||
* @method LeanSmooth.spring (float)
|
||||
* @param {float} current:float the current value
|
||||
* @param {float} target:float the value we are trying to reach
|
||||
* @param {float} currentVelocity:float the current velocity of the value
|
||||
* @param {float} smoothTime:float roughly the time it takes to reach the destination
|
||||
* @param {float} maxSpeed:float the top speed you want the value to move at (defaults to unlimited -1f)
|
||||
* @param {float} deltaTime:float the difference in time since the method was called (defaults to Time.deltaTime)
|
||||
* @param {float} [friction]:float rate at which the spring is slowed down once it reaches it's destination
|
||||
* @param {float} [accelRate]:float the rate it accelerates from it's initial position
|
||||
* @example
|
||||
* followVar = LeanSmooth.spring(followVar, destinationVar, ref followVelocity, 1.1f);\n
|
||||
* Debug.Log("current:"+followVar);
|
||||
*/
|
||||
public static float spring(float current, float target, ref float currentVelocity, float smoothTime, float maxSpeed = -1f, float deltaTime = -1f, float friction = 2f, float accelRate = 0.5f)
|
||||
{
|
||||
if (deltaTime < 0f)
|
||||
deltaTime = Time.deltaTime;
|
||||
|
||||
float diff = target - current;
|
||||
|
||||
currentVelocity += deltaTime / smoothTime * accelRate * diff;
|
||||
|
||||
currentVelocity *= (1f - deltaTime * friction);
|
||||
|
||||
if (maxSpeed > 0f && maxSpeed < Mathf.Abs(currentVelocity))
|
||||
currentVelocity = maxSpeed * Mathf.Sign(currentVelocity);
|
||||
|
||||
float returned = current + currentVelocity;
|
||||
|
||||
return returned;
|
||||
}
|
||||
|
||||
/**
|
||||
* <summary>Moves one value towards another (eases in and out to destination with possible overshoot bounciness)</summary>
|
||||
*
|
||||
* @method LeanSmooth.spring (Vector3)
|
||||
* @param {Vector3} current:float the current value
|
||||
* @param {Vector3} target:float the value we are trying to reach
|
||||
* @param {Vector3} currentVelocity:float the current velocity of the value
|
||||
* @param {float} smoothTime:float roughly the time it takes to reach the destination
|
||||
* @param {float} maxSpeed:float the top speed you want the value to move at (defaults to unlimited -1f)
|
||||
* @param {float} deltaTime:float the difference in time since the method was called (defaults to Time.deltaTime)
|
||||
* @param {float} [friction]:float rate at which the spring is slowed down once it reaches it's destination
|
||||
* @param {float} [accelRate]:float the rate it accelerates from it's initial position
|
||||
* @example
|
||||
* transform.position = LeanSmooth.spring(transform.position, destTrans.position, ref followVelocity, 1.1f);\n
|
||||
* Debug.Log("current:"+transform.position);
|
||||
*/
|
||||
public static Vector3 spring(Vector3 current, Vector3 target, ref Vector3 currentVelocity, float smoothTime, float maxSpeed = -1f, float deltaTime = -1f, float friction = 2f, float accelRate = 0.5f)
|
||||
{
|
||||
float x = spring(current.x, target.x, ref currentVelocity.x, smoothTime, maxSpeed, deltaTime, friction, accelRate);
|
||||
float y = spring(current.y, target.y, ref currentVelocity.y, smoothTime, maxSpeed, deltaTime, friction, accelRate);
|
||||
float z = spring(current.z, target.z, ref currentVelocity.z, smoothTime, maxSpeed, deltaTime, friction, accelRate);
|
||||
|
||||
return new Vector3(x, y, z);
|
||||
}
|
||||
|
||||
/**
|
||||
* <summary>Moves one color towards another (eases in and out to destination with possible overshoot bounciness)</summary>
|
||||
*
|
||||
* @method LeanSmooth.spring (Color)
|
||||
* @param {Color} current:float the current value
|
||||
* @param {Color} target:float the value we are trying to reach
|
||||
* @param {Color} currentVelocity:float the current velocity of the value
|
||||
* @param {float} smoothTime:float roughly the time it takes to reach the destination
|
||||
* @param {float} maxSpeed:float the top speed you want the value to move at (defaults to unlimited -1f)
|
||||
* @param {float} deltaTime:float the difference in time since the method was called (defaults to Time.deltaTime)
|
||||
* @param {float} [friction]:float rate at which the spring is slowed down once it reaches it's destination
|
||||
* @param {float} [accelRate]:float the rate it accelerates from it's initial position
|
||||
* @example
|
||||
* fromColor = LeanSmooth.spring(fromColor, transform.GetComponent<Renderer>().material.color, ref velocityColor, 1.1f);\n
|
||||
* Debug.Log("current:"+fromColor);
|
||||
*/
|
||||
public static Color spring(Color current, Color target, ref Color currentVelocity, float smoothTime, float maxSpeed = -1f, float deltaTime = -1f, float friction = 2f, float accelRate = 0.5f)
|
||||
{
|
||||
float r = spring(current.r, target.r, ref currentVelocity.r, smoothTime, maxSpeed, deltaTime, friction, accelRate);
|
||||
float g = spring(current.g, target.g, ref currentVelocity.g, smoothTime, maxSpeed, deltaTime, friction, accelRate);
|
||||
float b = spring(current.b, target.b, ref currentVelocity.b, smoothTime, maxSpeed, deltaTime, friction, accelRate);
|
||||
float a = spring(current.a, target.a, ref currentVelocity.a, smoothTime, maxSpeed, deltaTime, friction, accelRate);
|
||||
|
||||
return new Color(r, g, b, a);
|
||||
}
|
||||
|
||||
/**
|
||||
* <summary>Moves one value towards another (at a constant speed)</summary>
|
||||
*
|
||||
* @method LeanSmooth.linear (float)
|
||||
* @param {float} current:float the current value
|
||||
* @param {float} target:float the value we are trying to reach
|
||||
* @param {float} moveSpeed:float the speed at which to move towards the target
|
||||
* @param {float} deltaTime:float the difference in time since the method was called (defaults to Time.deltaTime)
|
||||
* @example
|
||||
* followVar = LeanSmooth.linear(followVar, destinationVar, 50f);\n
|
||||
* Debug.Log("current:"+followVar);
|
||||
*/
|
||||
public static float linear(float current, float target, float moveSpeed, float deltaTime = -1f)
|
||||
{
|
||||
if (deltaTime < 0f)
|
||||
deltaTime = Time.deltaTime;
|
||||
|
||||
bool targetGreater = (target > current);
|
||||
|
||||
float currentVelocity = deltaTime * moveSpeed * (targetGreater ? 1f : -1f);
|
||||
|
||||
float returned = current + currentVelocity;
|
||||
|
||||
float returnPassed = returned - target;
|
||||
if ((targetGreater && returnPassed > 0) || !targetGreater && returnPassed < 0)
|
||||
{ // Has passed point, return target
|
||||
return target;
|
||||
}
|
||||
|
||||
return returned;
|
||||
}
|
||||
|
||||
/**
|
||||
* <summary>Moves one value towards another (at a constant speed)</summary>
|
||||
*
|
||||
* @method LeanSmooth.linear (Vector3)
|
||||
* @param {Vector3} current:float the current value
|
||||
* @param {Vector3} target:float the value we are trying to reach
|
||||
* @param {float} moveSpeed:float the speed at which to move towards the target
|
||||
* @param {float} deltaTime:float the difference in time since the method was called (defaults to Time.deltaTime)
|
||||
* @example
|
||||
* transform.position = LeanSmooth.linear(transform.position, followTrans.position, 50f);\n
|
||||
* Debug.Log("current:"+transform.position);
|
||||
*/
|
||||
public static Vector3 linear(Vector3 current, Vector3 target, float moveSpeed, float deltaTime = -1f)
|
||||
{
|
||||
float x = linear(current.x, target.x, moveSpeed, deltaTime);
|
||||
float y = linear(current.y, target.y, moveSpeed, deltaTime);
|
||||
float z = linear(current.z, target.z, moveSpeed, deltaTime);
|
||||
|
||||
return new Vector3(x, y, z);
|
||||
}
|
||||
|
||||
/**
|
||||
* <summary>Moves one color towards another (at a constant speed)</summary>
|
||||
*
|
||||
* @method LeanSmooth.linear (Color)
|
||||
* @param {Color} current:float the current value
|
||||
* @param {Color} target:float the value we are trying to reach
|
||||
* @param {float} moveSpeed:float the speed at which to move towards the target
|
||||
* @param {float} deltaTime:float the difference in time since the method was called (defaults to Time.deltaTime)
|
||||
* @example
|
||||
* fromColor = LeanSmooth.linear(fromColor, transform.GetComponent<Renderer>().material.color, 50f);\n
|
||||
* Debug.Log("current:"+fromColor);
|
||||
*/
|
||||
public static Color linear(Color current, Color target, float moveSpeed)
|
||||
{
|
||||
float r = linear(current.r, target.r, moveSpeed);
|
||||
float g = linear(current.g, target.g, moveSpeed);
|
||||
float b = linear(current.b, target.b, moveSpeed);
|
||||
float a = linear(current.a, target.a, moveSpeed);
|
||||
|
||||
return new Color(r, g, b, a);
|
||||
}
|
||||
|
||||
/**
|
||||
* <summary>Moves one value towards another (with an ease that bounces back some when it reaches it's destination)</summary>
|
||||
*
|
||||
* @method LeanSmooth.bounceOut (float)
|
||||
* @param {float} current:float the current value
|
||||
* @param {float} target:float the value we are trying to reach
|
||||
* @param {float} currentVelocity:float the current velocity of the value
|
||||
* @param {float} smoothTime:float roughly the time it takes to reach the destination
|
||||
* @param {float} maxSpeed:float the top speed you want the value to move at (defaults to unlimited -1f)
|
||||
* @param {float} deltaTime:float the difference in time since the method was called (defaults to Time.deltaTime)
|
||||
* @param {float} [friction]:float rate at which the spring is slowed down once it reaches it's destination
|
||||
* @param {float} [accelRate]:float the rate it accelerates from it's initial position
|
||||
* @param {float} [hitDamping]:float the rate at which to dampen the bounciness of when it reaches it's destination
|
||||
* @example
|
||||
* followVar = LeanSmooth.bounceOut(followVar, destinationVar, ref followVelocity, 1.1f);\n
|
||||
* Debug.Log("current:"+followVar);
|
||||
*/
|
||||
public static float bounceOut(float current, float target, ref float currentVelocity, float smoothTime, float maxSpeed = -1f, float deltaTime = -1f, float friction = 2f, float accelRate = 0.5f, float hitDamping = 0.9f)
|
||||
{
|
||||
if (deltaTime < 0f)
|
||||
deltaTime = Time.deltaTime;
|
||||
|
||||
float diff = target - current;
|
||||
|
||||
currentVelocity += deltaTime / smoothTime * accelRate * diff;
|
||||
|
||||
currentVelocity *= (1f - deltaTime * friction);
|
||||
|
||||
if (maxSpeed > 0f && maxSpeed < Mathf.Abs(currentVelocity))
|
||||
currentVelocity = maxSpeed * Mathf.Sign(currentVelocity);
|
||||
|
||||
float returned = current + currentVelocity;
|
||||
|
||||
bool targetGreater = (target > current);
|
||||
float returnPassed = returned - target;
|
||||
if ((targetGreater && returnPassed > 0) || !targetGreater && returnPassed < 0)
|
||||
{ // Start a bounce
|
||||
currentVelocity = -currentVelocity * hitDamping;
|
||||
returned = current + currentVelocity;
|
||||
}
|
||||
|
||||
return returned;
|
||||
}
|
||||
|
||||
/**
|
||||
* <summary>Moves one value towards another (with an ease that bounces back some when it reaches it's destination)</summary>
|
||||
*
|
||||
* @method LeanSmooth.bounceOut (Vector3)
|
||||
* @param {Vector3} current:float the current value
|
||||
* @param {Vector3} target:float the value we are trying to reach
|
||||
* @param {Vector3} currentVelocity:float the current velocity of the value
|
||||
* @param {float} smoothTime:float roughly the time it takes to reach the destination
|
||||
* @param {float} maxSpeed:float the top speed you want the value to move at (defaults to unlimited -1f)
|
||||
* @param {float} deltaTime:float the difference in time since the method was called (defaults to Time.deltaTime)
|
||||
* @param {float} [friction]:float rate at which the spring is slowed down once it reaches it's destination
|
||||
* @param {float} [accelRate]:float the rate it accelerates from it's initial position
|
||||
* @param {float} [hitDamping]:float the rate at which to dampen the bounciness of when it reaches it's destination
|
||||
* @example
|
||||
* transform.position = LeanSmooth.bounceOut(transform.position, followTrans.position, ref followVelocity, 1.1f);\n
|
||||
* Debug.Log("current:"+transform.position);
|
||||
*/
|
||||
public static Vector3 bounceOut(Vector3 current, Vector3 target, ref Vector3 currentVelocity, float smoothTime, float maxSpeed = -1f, float deltaTime = -1f, float friction = 2f, float accelRate = 0.5f, float hitDamping = 0.9f)
|
||||
{
|
||||
float x = bounceOut(current.x, target.x, ref currentVelocity.x, smoothTime, maxSpeed, deltaTime, friction, accelRate, hitDamping);
|
||||
float y = bounceOut(current.y, target.y, ref currentVelocity.y, smoothTime, maxSpeed, deltaTime, friction, accelRate, hitDamping);
|
||||
float z = bounceOut(current.z, target.z, ref currentVelocity.z, smoothTime, maxSpeed, deltaTime, friction, accelRate, hitDamping);
|
||||
|
||||
return new Vector3(x, y, z);
|
||||
}
|
||||
|
||||
/**
|
||||
* <summary>Moves one color towards another (with an ease that bounces back some when it reaches it's destination)</summary>
|
||||
*
|
||||
* @method LeanSmooth.bounceOut (Color)
|
||||
* @param {Color} current:float the current value
|
||||
* @param {Color} target:float the value we are trying to reach
|
||||
* @param {Color} currentVelocity:float the current velocity of the value
|
||||
* @param {float} smoothTime:float roughly the time it takes to reach the destination
|
||||
* @param {float} maxSpeed:float the top speed you want the value to move at (defaults to unlimited -1f)
|
||||
* @param {float} deltaTime:float the difference in time since the method was called (defaults to Time.deltaTime)
|
||||
* @param {float} [friction]:float rate at which the spring is slowed down once it reaches it's destination
|
||||
* @param {float} [accelRate]:float the rate it accelerates from it's initial position
|
||||
* @param {float} [hitDamping]:float the rate at which to dampen the bounciness of when it reaches it's destination
|
||||
* @example
|
||||
* fromColor = LeanSmooth.bounceOut(fromColor, transform.GetComponent<Renderer>().material.color, ref followVelocity, 1.1f);\n
|
||||
* Debug.Log("current:" + fromColor);
|
||||
*/
|
||||
public static Color bounceOut(Color current, Color target, ref Color currentVelocity, float smoothTime, float maxSpeed = -1f, float deltaTime = -1f, float friction = 2f, float accelRate = 0.5f, float hitDamping = 0.9f)
|
||||
{
|
||||
float r = bounceOut(current.r, target.r, ref currentVelocity.r, smoothTime, maxSpeed, deltaTime, friction, accelRate, hitDamping);
|
||||
float g = bounceOut(current.g, target.g, ref currentVelocity.g, smoothTime, maxSpeed, deltaTime, friction, accelRate, hitDamping);
|
||||
float b = bounceOut(current.b, target.b, ref currentVelocity.b, smoothTime, maxSpeed, deltaTime, friction, accelRate, hitDamping);
|
||||
float a = bounceOut(current.a, target.a, ref currentVelocity.a, smoothTime, maxSpeed, deltaTime, friction, accelRate, hitDamping);
|
||||
|
||||
return new Color(r, g, b, a);
|
||||
}
|
||||
}
|
11
Assets/LeanTween/Framework/LeanSmooth.cs.meta
Normal file
11
Assets/LeanTween/Framework/LeanSmooth.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 1ca0f285af8dd4270bd759978223faad
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
123
Assets/LeanTween/Framework/LeanTest.cs
Normal file
123
Assets/LeanTween/Framework/LeanTest.cs
Normal file
|
@ -0,0 +1,123 @@
|
|||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
public class LeanTester : MonoBehaviour {
|
||||
public float timeout = 15f;
|
||||
|
||||
#if !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2 && !UNITY_4_3 && !UNITY_4_5
|
||||
public void Start(){
|
||||
StartCoroutine( timeoutCheck() );
|
||||
}
|
||||
|
||||
IEnumerator timeoutCheck(){
|
||||
float pauseEndTime = Time.realtimeSinceStartup + timeout;
|
||||
while (Time.realtimeSinceStartup < pauseEndTime)
|
||||
{
|
||||
yield return 0;
|
||||
}
|
||||
if(LeanTest.testsFinished==false){
|
||||
Debug.Log(LeanTest.formatB("Tests timed out!"));
|
||||
LeanTest.overview();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public class LeanTest : object {
|
||||
public static int expected = 0;
|
||||
private static int tests = 0;
|
||||
private static int passes = 0;
|
||||
|
||||
public static float timeout = 15f;
|
||||
public static bool timeoutStarted = false;
|
||||
public static bool testsFinished = false;
|
||||
|
||||
public static void debug( string name, bool didPass, string failExplaination = null){
|
||||
expect( didPass, name, failExplaination);
|
||||
}
|
||||
|
||||
public static void expect( bool didPass, string definition, string failExplaination = null){
|
||||
float len = printOutLength(definition);
|
||||
int paddingLen = 40-(int)(len*1.05f);
|
||||
#if UNITY_FLASH
|
||||
string padding = padRight(paddingLen);
|
||||
#else
|
||||
string padding = "".PadRight(paddingLen,"_"[0]);
|
||||
#endif
|
||||
string logName = formatB(definition) +" " + padding + " [ "+ (didPass ? formatC("pass","green") : formatC("fail","red")) +" ]";
|
||||
if(didPass==false && failExplaination!=null)
|
||||
logName += " - " + failExplaination;
|
||||
Debug.Log(logName);
|
||||
if(didPass)
|
||||
passes++;
|
||||
tests++;
|
||||
|
||||
// Debug.Log("tests:"+tests+" expected:"+expected);
|
||||
if(tests==expected && testsFinished==false){
|
||||
overview();
|
||||
}else if(tests>expected){
|
||||
Debug.Log(formatB("Too many tests for a final report!") + " set LeanTest.expected = "+tests);
|
||||
}
|
||||
|
||||
if(timeoutStarted==false){
|
||||
timeoutStarted = true;
|
||||
GameObject tester = new GameObject();
|
||||
tester.name = "~LeanTest";
|
||||
LeanTester test = tester.AddComponent(typeof(LeanTester)) as LeanTester;
|
||||
test.timeout = timeout;
|
||||
#if !UNITY_EDITOR
|
||||
tester.hideFlags = HideFlags.HideAndDontSave;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
public static string padRight(int len){
|
||||
string str = "";
|
||||
for(int i = 0; i < len; i++){
|
||||
str += "_";
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
public static float printOutLength( string str ){
|
||||
float len = 0.0f;
|
||||
for(int i = 0; i < str.Length; i++){
|
||||
if(str[i]=="I"[0]){
|
||||
len += 0.5f;
|
||||
}else if(str[i]=="J"[0]){
|
||||
len += 0.85f;
|
||||
}else{
|
||||
len += 1.0f;
|
||||
}
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
public static string formatBC( string str, string color ){
|
||||
return formatC(formatB(str),color);
|
||||
}
|
||||
|
||||
public static string formatB( string str ){
|
||||
#if UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2
|
||||
return str;
|
||||
#else
|
||||
return "<b>"+ str + "</b>";
|
||||
#endif
|
||||
}
|
||||
|
||||
public static string formatC( string str, string color ){
|
||||
#if UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2
|
||||
return str;
|
||||
#else
|
||||
return "<color="+color+">"+ str + "</color>";
|
||||
#endif
|
||||
}
|
||||
|
||||
public static void overview(){
|
||||
testsFinished = true;
|
||||
int failedCnt = (expected-passes);
|
||||
string failedStr = failedCnt > 0 ? formatBC(""+failedCnt,"red") : ""+failedCnt;
|
||||
Debug.Log(formatB("Final Report:")+" _____________________ PASSED: "+formatBC(""+passes,"green")+" FAILED: "+failedStr+" ");
|
||||
}
|
||||
}
|
||||
|
12
Assets/LeanTween/Framework/LeanTest.cs.meta
Normal file
12
Assets/LeanTween/Framework/LeanTest.cs.meta
Normal file
|
@ -0,0 +1,12 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 82464f26ca2ba284a8f92f51248c574a
|
||||
timeCreated: 1427917971
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
4090
Assets/LeanTween/Framework/LeanTween.cs
Normal file
4090
Assets/LeanTween/Framework/LeanTween.cs
Normal file
File diff suppressed because it is too large
Load diff
12
Assets/LeanTween/Framework/LeanTween.cs.meta
Normal file
12
Assets/LeanTween/Framework/LeanTween.cs.meta
Normal file
|
@ -0,0 +1,12 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 9c2f4b27196f84954b44753aaac214bb
|
||||
timeCreated: 1463137984
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
BIN
Assets/LeanTween/Framework/LeanTween.dll.zip
Normal file
BIN
Assets/LeanTween/Framework/LeanTween.dll.zip
Normal file
Binary file not shown.
8
Assets/LeanTween/Framework/LeanTween.dll.zip.meta
Normal file
8
Assets/LeanTween/Framework/LeanTween.dll.zip.meta
Normal file
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: ffeadda6aaa064923a3f7e28ff26afb1
|
||||
timeCreated: 1477948563
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
187
Assets/LeanTween/Framework/LeanTweenExt.cs
Normal file
187
Assets/LeanTween/Framework/LeanTweenExt.cs
Normal file
|
@ -0,0 +1,187 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System;
|
||||
|
||||
public static class LeanTweenExt
|
||||
{
|
||||
//LeanTween.addListener
|
||||
//LeanTween.alpha
|
||||
public static LTDescr LeanAlpha(this GameObject gameObject, float to, float time) { return LeanTween.alpha(gameObject, to, time); }
|
||||
//LeanTween.alphaCanvas
|
||||
public static LTDescr LeanAlphaVertex(this GameObject gameObject, float to, float time) { return LeanTween.alphaVertex(gameObject, to, time); }
|
||||
//LeanTween.alpha (RectTransform)
|
||||
public static LTDescr LeanAlpha(this RectTransform rectTransform, float to, float time) { return LeanTween.alpha(rectTransform, to, time); }
|
||||
//LeanTween.alphaCanvas
|
||||
public static LTDescr LeanAlpha(this CanvasGroup canvas, float to, float time) { return LeanTween.alphaCanvas(canvas, to, time); }
|
||||
//LeanTween.alphaText
|
||||
public static LTDescr LeanAlphaText(this RectTransform rectTransform, float to, float time) { return LeanTween.alphaText(rectTransform, to, time); }
|
||||
//LeanTween.cancel
|
||||
public static void LeanCancel(this GameObject gameObject) { LeanTween.cancel(gameObject); }
|
||||
public static void LeanCancel(this GameObject gameObject, bool callOnComplete) { LeanTween.cancel(gameObject, callOnComplete); }
|
||||
public static void LeanCancel(this GameObject gameObject, int uniqueId, bool callOnComplete = false) { LeanTween.cancel(gameObject, uniqueId, callOnComplete); }
|
||||
//LeanTween.cancel
|
||||
public static void LeanCancel(this RectTransform rectTransform) { LeanTween.cancel(rectTransform); }
|
||||
//LeanTween.cancelAll
|
||||
//LeanTween.color
|
||||
public static LTDescr LeanColor(this GameObject gameObject, Color to, float time) { return LeanTween.color(gameObject, to, time); }
|
||||
//LeanTween.colorText
|
||||
public static LTDescr LeanColorText(this RectTransform rectTransform, Color to, float time) { return LeanTween.colorText(rectTransform, to, time); }
|
||||
//LeanTween.delayedCall
|
||||
public static LTDescr LeanDelayedCall(this GameObject gameObject, float delayTime, System.Action callback) { return LeanTween.delayedCall(gameObject, delayTime, callback); }
|
||||
public static LTDescr LeanDelayedCall(this GameObject gameObject, float delayTime, System.Action<object> callback) { return LeanTween.delayedCall(gameObject, delayTime, callback); }
|
||||
|
||||
//LeanTween.isPaused
|
||||
public static bool LeanIsPaused(this GameObject gameObject) { return LeanTween.isPaused(gameObject); }
|
||||
public static bool LeanIsPaused(this RectTransform rectTransform) { return LeanTween.isPaused(rectTransform); }
|
||||
|
||||
//LeanTween.isTweening
|
||||
public static bool LeanIsTweening(this GameObject gameObject) { return LeanTween.isTweening(gameObject); }
|
||||
//LeanTween.isTweening
|
||||
//LeanTween.move
|
||||
public static LTDescr LeanMove(this GameObject gameObject, Vector3 to, float time) { return LeanTween.move(gameObject, to, time); }
|
||||
public static LTDescr LeanMove(this Transform transform, Vector3 to, float time) { return LeanTween.move(transform.gameObject, to, time); }
|
||||
public static LTDescr LeanMove(this RectTransform rectTransform, Vector3 to, float time) { return LeanTween.move(rectTransform, to, time); }
|
||||
//LeanTween.move
|
||||
public static LTDescr LeanMove(this GameObject gameObject, Vector2 to, float time) { return LeanTween.move(gameObject, to, time); }
|
||||
public static LTDescr LeanMove(this Transform transform, Vector2 to, float time) { return LeanTween.move(transform.gameObject, to, time); }
|
||||
//LeanTween.move
|
||||
public static LTDescr LeanMove(this GameObject gameObject, Vector3[] to, float time) { return LeanTween.move(gameObject, to, time); }
|
||||
public static LTDescr LeanMove(this GameObject gameObject, LTBezierPath to, float time) { return LeanTween.move(gameObject, to, time); }
|
||||
public static LTDescr LeanMove(this GameObject gameObject, LTSpline to, float time) { return LeanTween.move(gameObject, to, time); }
|
||||
public static LTDescr LeanMove(this Transform transform, Vector3[] to, float time) { return LeanTween.move(transform.gameObject, to, time); }
|
||||
public static LTDescr LeanMove(this Transform transform, LTBezierPath to, float time) { return LeanTween.move(transform.gameObject, to, time); }
|
||||
public static LTDescr LeanMove(this Transform transform, LTSpline to, float time) { return LeanTween.move(transform.gameObject, to, time); }
|
||||
//LeanTween.moveLocal
|
||||
public static LTDescr LeanMoveLocal(this GameObject gameObject, Vector3 to, float time) { return LeanTween.moveLocal(gameObject, to, time); }
|
||||
public static LTDescr LeanMoveLocal(this GameObject gameObject, LTBezierPath to, float time) { return LeanTween.moveLocal(gameObject, to, time); }
|
||||
public static LTDescr LeanMoveLocal(this GameObject gameObject, LTSpline to, float time) { return LeanTween.moveLocal(gameObject, to, time); }
|
||||
public static LTDescr LeanMoveLocal(this Transform transform, Vector3 to, float time) { return LeanTween.moveLocal(transform.gameObject, to, time); }
|
||||
public static LTDescr LeanMoveLocal(this Transform transform, LTBezierPath to, float time) { return LeanTween.moveLocal(transform.gameObject, to, time); }
|
||||
public static LTDescr LeanMoveLocal(this Transform transform, LTSpline to, float time) { return LeanTween.moveLocal(transform.gameObject, to, time); }
|
||||
//LeanTween.moveLocal
|
||||
public static LTDescr LeanMoveLocalX(this GameObject gameObject, float to, float time) { return LeanTween.moveLocalX(gameObject, to, time); }
|
||||
public static LTDescr LeanMoveLocalY(this GameObject gameObject, float to, float time) { return LeanTween.moveLocalY(gameObject, to, time); }
|
||||
public static LTDescr LeanMoveLocalZ(this GameObject gameObject, float to, float time) { return LeanTween.moveLocalZ(gameObject, to, time); }
|
||||
public static LTDescr LeanMoveLocalX(this Transform transform, float to, float time) { return LeanTween.moveLocalX(transform.gameObject, to, time); }
|
||||
public static LTDescr LeanMoveLocalY(this Transform transform, float to, float time) { return LeanTween.moveLocalY(transform.gameObject, to, time); }
|
||||
public static LTDescr LeanMoveLocalZ(this Transform transform, float to, float time) { return LeanTween.moveLocalZ(transform.gameObject, to, time); }
|
||||
//LeanTween.moveSpline
|
||||
public static LTDescr LeanMoveSpline(this GameObject gameObject, Vector3[] to, float time) { return LeanTween.moveSpline(gameObject, to, time); }
|
||||
public static LTDescr LeanMoveSpline(this GameObject gameObject, LTSpline to, float time) { return LeanTween.moveSpline(gameObject, to, time); }
|
||||
public static LTDescr LeanMoveSpline(this Transform transform, Vector3[] to, float time) { return LeanTween.moveSpline(transform.gameObject, to, time); }
|
||||
public static LTDescr LeanMoveSpline(this Transform transform, LTSpline to, float time) { return LeanTween.moveSpline(transform.gameObject, to, time); }
|
||||
//LeanTween.moveSplineLocal
|
||||
public static LTDescr LeanMoveSplineLocal(this GameObject gameObject, Vector3[] to, float time) { return LeanTween.moveSplineLocal(gameObject, to, time); }
|
||||
public static LTDescr LeanMoveSplineLocal(this Transform transform, Vector3[] to, float time) { return LeanTween.moveSplineLocal(transform.gameObject, to, time); }
|
||||
//LeanTween.moveX
|
||||
public static LTDescr LeanMoveX(this GameObject gameObject, float to, float time) { return LeanTween.moveX(gameObject, to, time); }
|
||||
public static LTDescr LeanMoveX(this Transform transform, float to, float time) { return LeanTween.moveX(transform.gameObject, to, time); }
|
||||
//LeanTween.moveX (RectTransform)
|
||||
public static LTDescr LeanMoveX(this RectTransform rectTransform, float to, float time) { return LeanTween.moveX(rectTransform, to, time); }
|
||||
//LeanTween.moveY
|
||||
public static LTDescr LeanMoveY(this GameObject gameObject, float to, float time) { return LeanTween.moveY(gameObject, to, time); }
|
||||
public static LTDescr LeanMoveY(this Transform transform, float to, float time) { return LeanTween.moveY(transform.gameObject, to, time); }
|
||||
//LeanTween.moveY (RectTransform)
|
||||
public static LTDescr LeanMoveY(this RectTransform rectTransform, float to, float time) { return LeanTween.moveY(rectTransform, to, time); }
|
||||
//LeanTween.moveZ
|
||||
public static LTDescr LeanMoveZ(this GameObject gameObject, float to, float time) { return LeanTween.moveZ(gameObject, to, time); }
|
||||
public static LTDescr LeanMoveZ(this Transform transform, float to, float time) { return LeanTween.moveZ(transform.gameObject, to, time); }
|
||||
//LeanTween.moveZ (RectTransform)
|
||||
public static LTDescr LeanMoveZ(this RectTransform rectTransform, float to, float time) { return LeanTween.moveZ(rectTransform, to, time); }
|
||||
//LeanTween.pause
|
||||
public static void LeanPause(this GameObject gameObject) { LeanTween.pause(gameObject); }
|
||||
//LeanTween.play
|
||||
public static LTDescr LeanPlay(this RectTransform rectTransform, UnityEngine.Sprite[] sprites) { return LeanTween.play(rectTransform, sprites); }
|
||||
//LeanTween.removeListener
|
||||
//LeanTween.resume
|
||||
public static void LeanResume(this GameObject gameObject) { LeanTween.resume(gameObject); }
|
||||
//LeanTween.resumeAll
|
||||
//LeanTween.rotate
|
||||
public static LTDescr LeanRotate(this GameObject gameObject, Vector3 to, float time) { return LeanTween.rotate(gameObject, to, time); }
|
||||
public static LTDescr LeanRotate(this Transform transform, Vector3 to, float time) { return LeanTween.rotate(transform.gameObject, to, time); }
|
||||
//LeanTween.rotate
|
||||
//LeanTween.rotate (RectTransform)
|
||||
public static LTDescr LeanRotate(this RectTransform rectTransform, Vector3 to, float time) { return LeanTween.rotate(rectTransform, to, time); }
|
||||
//LeanTween.rotateAround
|
||||
public static LTDescr LeanRotateAround(this GameObject gameObject, Vector3 axis, float add, float time) { return LeanTween.rotateAround(gameObject, axis, add, time); }
|
||||
public static LTDescr LeanRotateAround(this Transform transform, Vector3 axis, float add, float time) { return LeanTween.rotateAround(transform.gameObject, axis, add, time); }
|
||||
//LeanTween.rotateAround (RectTransform)
|
||||
public static LTDescr LeanRotateAround(this RectTransform rectTransform, Vector3 axis, float add, float time) { return LeanTween.rotateAround(rectTransform, axis, add, time); }
|
||||
//LeanTween.rotateAroundLocal
|
||||
public static LTDescr LeanRotateAroundLocal(this GameObject gameObject, Vector3 axis, float add, float time) { return LeanTween.rotateAroundLocal(gameObject, axis, add, time); }
|
||||
public static LTDescr LeanRotateAroundLocal(this Transform transform, Vector3 axis, float add, float time) { return LeanTween.rotateAroundLocal(transform.gameObject, axis, add, time); }
|
||||
//LeanTween.rotateAround (RectTransform)
|
||||
public static LTDescr LeanRotateAroundLocal(this RectTransform rectTransform, Vector3 axis, float add, float time) { return LeanTween.rotateAroundLocal(rectTransform, axis, add, time); }
|
||||
//LeanTween.rotateLocal
|
||||
//LeanTween.rotateX
|
||||
public static LTDescr LeanRotateX(this GameObject gameObject, float to, float time) { return LeanTween.rotateX(gameObject, to, time); }
|
||||
public static LTDescr LeanRotateX(this Transform transform, float to, float time) { return LeanTween.rotateX(transform.gameObject, to, time); }
|
||||
//LeanTween.rotateY
|
||||
public static LTDescr LeanRotateY(this GameObject gameObject, float to, float time) { return LeanTween.rotateY(gameObject, to, time); }
|
||||
public static LTDescr LeanRotateY(this Transform transform, float to, float time) { return LeanTween.rotateY(transform.gameObject, to, time); }
|
||||
//LeanTween.rotateZ
|
||||
public static LTDescr LeanRotateZ(this GameObject gameObject, float to, float time) { return LeanTween.rotateZ(gameObject, to, time); }
|
||||
public static LTDescr LeanRotateZ(this Transform transform, float to, float time) { return LeanTween.rotateZ(transform.gameObject, to, time); }
|
||||
//LeanTween.scale
|
||||
public static LTDescr LeanScale(this GameObject gameObject, Vector3 to, float time) { return LeanTween.scale(gameObject, to, time); }
|
||||
public static LTDescr LeanScale(this Transform transform, Vector3 to, float time) { return LeanTween.scale(transform.gameObject, to, time); }
|
||||
//LeanTween.scale (GUI)
|
||||
//LeanTween.scale (RectTransform)
|
||||
public static LTDescr LeanScale(this RectTransform rectTransform, Vector3 to, float time) { return LeanTween.scale(rectTransform, to, time); }
|
||||
//LeanTween.scaleX
|
||||
public static LTDescr LeanScaleX(this GameObject gameObject, float to, float time) { return LeanTween.scaleX(gameObject, to, time); }
|
||||
public static LTDescr LeanScaleX(this Transform transform, float to, float time) { return LeanTween.scaleX(transform.gameObject, to, time); }
|
||||
//LeanTween.scaleY
|
||||
public static LTDescr LeanScaleY(this GameObject gameObject, float to, float time) { return LeanTween.scaleY(gameObject, to, time); }
|
||||
public static LTDescr LeanScaleY(this Transform transform, float to, float time) { return LeanTween.scaleY(transform.gameObject, to, time); }
|
||||
//LeanTween.scaleZ
|
||||
public static LTDescr LeanScaleZ(this GameObject gameObject, float to, float time) { return LeanTween.scaleZ(gameObject, to, time); }
|
||||
public static LTDescr LeanScaleZ(this Transform transform, float to, float time) { return LeanTween.scaleZ(transform.gameObject, to, time); }
|
||||
//LeanTween.sequence
|
||||
//LeanTween.size (RectTransform)
|
||||
public static LTDescr LeanSize(this RectTransform rectTransform, Vector2 to, float time) { return LeanTween.size(rectTransform, to, time); }
|
||||
//LeanTween.tweensRunning
|
||||
//LeanTween.value (Color)
|
||||
public static LTDescr LeanValue(this GameObject gameObject, Color from, Color to, float time) { return LeanTween.value(gameObject, from, to, time); }
|
||||
//LeanTween.value (Color)
|
||||
//LeanTween.value (float)
|
||||
public static LTDescr LeanValue(this GameObject gameObject, float from, float to, float time) { return LeanTween.value(gameObject, from, to, time); }
|
||||
public static LTDescr LeanValue(this GameObject gameObject, Vector2 from, Vector2 to, float time) { return LeanTween.value(gameObject, from, to, time); }
|
||||
public static LTDescr LeanValue(this GameObject gameObject, Vector3 from, Vector3 to, float time) { return LeanTween.value(gameObject, from, to, time); }
|
||||
//LeanTween.value (float)
|
||||
public static LTDescr LeanValue(this GameObject gameObject, Action<float> callOnUpdate, float from, float to, float time) { return LeanTween.value(gameObject, callOnUpdate, from, to, time); }
|
||||
public static LTDescr LeanValue(this GameObject gameObject, Action<float, float> callOnUpdate, float from, float to, float time) { return LeanTween.value(gameObject, callOnUpdate, from, to, time); }
|
||||
public static LTDescr LeanValue(this GameObject gameObject, Action<float, object> callOnUpdate, float from, float to, float time) { return LeanTween.value(gameObject, callOnUpdate, from, to, time); }
|
||||
public static LTDescr LeanValue(this GameObject gameObject, Action<Color> callOnUpdate, Color from, Color to, float time) { return LeanTween.value(gameObject, callOnUpdate, from, to, time); }
|
||||
public static LTDescr LeanValue(this GameObject gameObject, Action<Vector2> callOnUpdate, Vector2 from, Vector2 to, float time) { return LeanTween.value(gameObject, callOnUpdate, from, to, time); }
|
||||
public static LTDescr LeanValue(this GameObject gameObject, Action<Vector3> callOnUpdate, Vector3 from, Vector3 to, float time) { return LeanTween.value(gameObject, callOnUpdate, from, to, time); }
|
||||
|
||||
public static void LeanSetPosX(this Transform transform, float val){
|
||||
transform.position = new Vector3(val, transform.position.y, transform.position.z);
|
||||
}
|
||||
public static void LeanSetPosY(this Transform transform, float val) {
|
||||
transform.position = new Vector3(transform.position.x, val, transform.position.z);
|
||||
}
|
||||
public static void LeanSetPosZ(this Transform transform, float val) {
|
||||
transform.position = new Vector3(transform.position.x, transform.position.y, val);
|
||||
}
|
||||
|
||||
public static void LeanSetLocalPosX(this Transform transform, float val)
|
||||
{
|
||||
transform.localPosition = new Vector3(val, transform.localPosition.y, transform.localPosition.z);
|
||||
}
|
||||
public static void LeanSetLocalPosY(this Transform transform, float val)
|
||||
{
|
||||
transform.localPosition = new Vector3(transform.localPosition.x, val, transform.localPosition.z);
|
||||
}
|
||||
public static void LeanSetLocalPosZ(this Transform transform, float val)
|
||||
{
|
||||
transform.localPosition = new Vector3(transform.localPosition.x, transform.localPosition.y, val);
|
||||
}
|
||||
|
||||
public static Color LeanColor(this Transform transform)
|
||||
{
|
||||
return transform.GetComponent<Renderer>().material.color;
|
||||
}
|
||||
}
|
13
Assets/LeanTween/Framework/LeanTweenExt.cs.meta
Normal file
13
Assets/LeanTween/Framework/LeanTweenExt.cs.meta
Normal file
|
@ -0,0 +1,13 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 5dbe851e9c0814f1d8f514ecf70f675d
|
||||
timeCreated: 1533842565
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Add table
Add a link
Reference in a new issue