diff --git a/Assets/Demo/7. Unity UI.unity b/Assets/Demo/7. Unity UI.unity new file mode 100644 index 0000000..54a7c2e Binary files /dev/null and b/Assets/Demo/7. Unity UI.unity differ diff --git a/Assets/Demo/7. Unity UI.unity.meta b/Assets/Demo/7. Unity UI.unity.meta new file mode 100644 index 0000000..dcd0a70 --- /dev/null +++ b/Assets/Demo/7. Unity UI.unity.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 254f906bfb1924e81a9726d76c592128 +timeCreated: 1429710093 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Demo/scripts/UnityGUITween.cs b/Assets/Demo/scripts/UnityGUITween.cs new file mode 100644 index 0000000..bd9e54b --- /dev/null +++ b/Assets/Demo/scripts/UnityGUITween.cs @@ -0,0 +1,24 @@ +using UnityEngine; +using UnityEngine.UI; +using System.Collections; + +public class UnityGUITween : BaseDemoGUI +{ + public RectTransform anchorImage; + public RectTransform sizeOffsetImage; + + void Start() + { + // this will run indefinitely. + Go.to( anchorImage, 4, new GoTweenConfig() + .anchorMin(Vector2.one * 0.25f) + .anchorMax(Vector2.one * 0.75f) + .setIterations( -1, GoLoopType.PingPong ) ); + + // hook this one up so we can play with the easeTypes in the UI. + _tween = Go.to( sizeOffsetImage, 2, new GoTweenConfig() + .offsetMax(Vector2.right * 100) + .sizeDelta(Vector2.one * -50f, true) + .setIterations( -1, GoLoopType.PingPong ) ); + } +} diff --git a/Assets/Demo/scripts/UnityGUITween.cs.meta b/Assets/Demo/scripts/UnityGUITween.cs.meta new file mode 100644 index 0000000..0cac9e9 --- /dev/null +++ b/Assets/Demo/scripts/UnityGUITween.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: cb7b08587d8bb43aab6c975ad7327203 +timeCreated: 1429710378 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/GoKit/GoProxyProp.cs.meta b/Assets/Plugins/GoKit/GoProxyProp.cs.meta new file mode 100644 index 0000000..f7f5435 --- /dev/null +++ b/Assets/Plugins/GoKit/GoProxyProp.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 59c5798f5556a4f5f901929754f0983d +timeCreated: 1429675599 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/GoKit/GoTweenConfig.cs b/Assets/Plugins/GoKit/GoTweenConfig.cs index a37677f..c010acc 100644 --- a/Assets/Plugins/GoKit/GoTweenConfig.cs +++ b/Assets/Plugins/GoKit/GoTweenConfig.cs @@ -170,6 +170,94 @@ public GoTweenConfig localRotation( Quaternion endValue, bool isRelative = false } + /// + /// anchoredPosition tween + /// + public GoTweenConfig anchoredPosition( Vector2 endValue, bool isRelative = false ) + { + var prop = new AnchoredPositionTweenProperty( endValue, isRelative ); + _tweenProperties.Add( prop ); + + return this; + } + + /// + /// anchoredPosition3D tween + /// + public GoTweenConfig anchoredPosition3D( Vector3 endValue, bool isRelative = false ) + { + var prop = new AnchoredPosition3DTweenProperty( endValue, isRelative ); + _tweenProperties.Add( prop ); + + return this; + } + + /// + /// anchorMax tween + /// + public GoTweenConfig anchorMax( Vector2 endValue, bool isRelative = false ) + { + var prop = new AnchorMaxTweenProperty( endValue, isRelative ); + _tweenProperties.Add( prop ); + + return this; + } + + /// + /// anchorMin tween + /// + public GoTweenConfig anchorMin( Vector2 endValue, bool isRelative = false ) + { + var prop = new AnchorMinTweenProperty( endValue, isRelative ); + _tweenProperties.Add( prop ); + + return this; + } + + /// + /// offsetMax tween + /// + public GoTweenConfig offsetMax( Vector2 endValue, bool isRelative = false ) + { + var prop = new OffsetTweenProperty( endValue, isRelative, true ); + _tweenProperties.Add( prop ); + + return this; + } + + /// + /// offsetMin tween + /// + public GoTweenConfig offsetMin( Vector2 endValue, bool isRelative = false ) + { + var prop = new OffsetTweenProperty( endValue, isRelative ); + _tweenProperties.Add( prop ); + + return this; + } + + /// + /// pivot tween + /// + public GoTweenConfig pivot( Vector2 endValue, bool isRelative = false ) + { + var prop = new PivotTweenProperty( endValue, isRelative ); + _tweenProperties.Add( prop ); + + return this; + } + + /// + /// sizeDelta tween + /// + public GoTweenConfig sizeDelta( Vector2 endValue, bool isRelative = false ) + { + var prop = new SizeDeltaTweenProperty( endValue, isRelative ); + _tweenProperties.Add( prop ); + + return this; + } + /// /// material color tween /// diff --git a/Assets/Plugins/GoKit/properties/specificTypes/AnchorMaxTweenProperty.cs b/Assets/Plugins/GoKit/properties/specificTypes/AnchorMaxTweenProperty.cs new file mode 100644 index 0000000..980eb77 --- /dev/null +++ b/Assets/Plugins/GoKit/properties/specificTypes/AnchorMaxTweenProperty.cs @@ -0,0 +1,61 @@ +using UnityEngine; +using System.Collections; + + +public class AnchorMaxTweenProperty : AbstractTweenProperty +{ + protected RectTransform _target; + + protected Vector2 _originalEndValue; + protected Vector2 _startValue; + protected Vector2 _endValue; + protected Vector2 _diffValue; + + public AnchorMaxTweenProperty( Vector2 endValue, bool isRelative = false) : base( isRelative ) + { + _originalEndValue = endValue; + } + + public override bool validateTarget( object target ) + { + return target is RectTransform; + } + + public override void prepareForUse() + { + _target = _ownerTween.target as RectTransform; + + _endValue = _originalEndValue; + + if( _ownerTween.isFrom ) + { + _startValue = _isRelative ? _endValue + _target.anchorMax : _endValue; + _endValue = _target.anchorMax; + } + else + { + _startValue = _target.anchorMax; + } + + if( _isRelative && !_ownerTween.isFrom ) + _diffValue = _endValue; + else + _diffValue = _endValue - _startValue; + } + + + public override void tick( float totalElapsedTime ) + { + var easedTime = _easeFunction( totalElapsedTime, 0, 1, _ownerTween.duration ); + var vec = GoTweenUtils.unclampedVector2Lerp( _startValue, _diffValue, easedTime ); + + _target.anchorMax = vec; + } + + + public void resetWithNewEndValue( Vector2 endValue ) + { + _originalEndValue = endValue; + prepareForUse(); + } +} diff --git a/Assets/Plugins/GoKit/properties/specificTypes/AnchorMaxTweenProperty.cs.meta b/Assets/Plugins/GoKit/properties/specificTypes/AnchorMaxTweenProperty.cs.meta new file mode 100644 index 0000000..7ab1741 --- /dev/null +++ b/Assets/Plugins/GoKit/properties/specificTypes/AnchorMaxTweenProperty.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: d2f5c38d9a9de4ea19a3ac83e38cf5b7 +timeCreated: 1429710879 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/GoKit/properties/specificTypes/AnchorMinTweenProperty.cs b/Assets/Plugins/GoKit/properties/specificTypes/AnchorMinTweenProperty.cs new file mode 100644 index 0000000..749da36 --- /dev/null +++ b/Assets/Plugins/GoKit/properties/specificTypes/AnchorMinTweenProperty.cs @@ -0,0 +1,62 @@ +using UnityEngine; +using System.Collections; + + +public class AnchorMinTweenProperty : AbstractTweenProperty +{ + protected RectTransform _target; + + protected Vector2 _originalEndValue; + protected Vector2 _startValue; + protected Vector2 _endValue; + protected Vector2 _diffValue; + + public AnchorMinTweenProperty( Vector2 endValue, bool isRelative = false) : base( isRelative ) + { + _originalEndValue = endValue; + } + + public override bool validateTarget( object target ) + { + return target is RectTransform; + } + + public override void prepareForUse() + { + _target = _ownerTween.target as RectTransform; + + _endValue = _originalEndValue; + + if( _ownerTween.isFrom ) + { + _startValue = _isRelative ? _endValue + _target.anchorMin : _endValue; + _endValue = _target.anchorMin; + } + else + { + _startValue = _target.anchorMin; + } + + if( _isRelative && !_ownerTween.isFrom ) + _diffValue = _endValue; + else + _diffValue = _endValue - _startValue; + } + + + public override void tick( float totalElapsedTime ) + { + var easedTime = _easeFunction( totalElapsedTime, 0, 1, _ownerTween.duration ); + var vec = GoTweenUtils.unclampedVector2Lerp( _startValue, _diffValue, easedTime ); + + _target.anchorMin = vec; + } + + + public void resetWithNewEndValue( Vector2 endValue ) + { + _originalEndValue = endValue; + prepareForUse(); + } + +} diff --git a/Assets/Plugins/GoKit/properties/specificTypes/AnchorMinTweenProperty.cs.meta b/Assets/Plugins/GoKit/properties/specificTypes/AnchorMinTweenProperty.cs.meta new file mode 100644 index 0000000..ae45ccc --- /dev/null +++ b/Assets/Plugins/GoKit/properties/specificTypes/AnchorMinTweenProperty.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 2fbf2eff73a1b45138af465b52171594 +timeCreated: 1429710870 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/GoKit/properties/specificTypes/AnchoredPosition3DTweenProperty.cs b/Assets/Plugins/GoKit/properties/specificTypes/AnchoredPosition3DTweenProperty.cs new file mode 100644 index 0000000..a5123c9 --- /dev/null +++ b/Assets/Plugins/GoKit/properties/specificTypes/AnchoredPosition3DTweenProperty.cs @@ -0,0 +1,62 @@ +using UnityEngine; +using System.Collections; + + +public class AnchoredPosition3DTweenProperty : AbstractTweenProperty +{ + protected RectTransform _target; + + protected Vector3 _originalEndValue; + protected Vector3 _startValue; + protected Vector3 _endValue; + protected Vector3 _diffValue; + + public AnchoredPosition3DTweenProperty( Vector3 endValue, bool isRelative = false) : base( isRelative ) + { + _originalEndValue = endValue; + } + + public override bool validateTarget( object target ) + { + return target is RectTransform; + } + + public override void prepareForUse() + { + _target = _ownerTween.target as RectTransform; + + _endValue = _originalEndValue; + + if( _ownerTween.isFrom ) + { + _startValue = _isRelative ? _endValue + _target.anchoredPosition3D : _endValue; + _endValue = _target.anchoredPosition3D; + } + else + { + _startValue = _target.anchoredPosition3D; + } + + if( _isRelative && !_ownerTween.isFrom ) + _diffValue = _endValue; + else + _diffValue = _endValue - _startValue; + } + + + public override void tick( float totalElapsedTime ) + { + var easedTime = _easeFunction( totalElapsedTime, 0, 1, _ownerTween.duration ); + var vec = GoTweenUtils.unclampedVector3Lerp( _startValue, _diffValue, easedTime ); + + _target.anchoredPosition3D = vec; + } + + + public void resetWithNewEndValue( Vector3 endValue ) + { + _originalEndValue = endValue; + prepareForUse(); + } + +} diff --git a/Assets/Plugins/GoKit/properties/specificTypes/AnchoredPosition3DTweenProperty.cs.meta b/Assets/Plugins/GoKit/properties/specificTypes/AnchoredPosition3DTweenProperty.cs.meta new file mode 100644 index 0000000..b116d9c --- /dev/null +++ b/Assets/Plugins/GoKit/properties/specificTypes/AnchoredPosition3DTweenProperty.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 8bc14a3ce3aab450eb8dc0b614a573c2 +timeCreated: 1429678705 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/GoKit/properties/specificTypes/AnchoredPositionTweenProperty.cs b/Assets/Plugins/GoKit/properties/specificTypes/AnchoredPositionTweenProperty.cs new file mode 100644 index 0000000..3fb41e6 --- /dev/null +++ b/Assets/Plugins/GoKit/properties/specificTypes/AnchoredPositionTweenProperty.cs @@ -0,0 +1,62 @@ +using UnityEngine; +using System.Collections; + + +public class AnchoredPositionTweenProperty : AbstractTweenProperty +{ + protected RectTransform _target; + + protected Vector2 _originalEndValue; + protected Vector2 _startValue; + protected Vector2 _endValue; + protected Vector2 _diffValue; + + public AnchoredPositionTweenProperty( Vector2 endValue, bool isRelative = false) : base( isRelative ) + { + _originalEndValue = endValue; + } + + public override bool validateTarget( object target ) + { + return target is RectTransform; + } + + public override void prepareForUse() + { + _target = _ownerTween.target as RectTransform; + + _endValue = _originalEndValue; + + if( _ownerTween.isFrom ) + { + _startValue = _isRelative ? _endValue + _target.anchoredPosition : _endValue; + _endValue = _target.anchoredPosition; + } + else + { + _startValue = _target.anchoredPosition; + } + + if( _isRelative && !_ownerTween.isFrom ) + _diffValue = _endValue; + else + _diffValue = _endValue - _startValue; + } + + + public override void tick( float totalElapsedTime ) + { + var easedTime = _easeFunction( totalElapsedTime, 0, 1, _ownerTween.duration ); + var vec = GoTweenUtils.unclampedVector2Lerp( _startValue, _diffValue, easedTime ); + + _target.anchoredPosition = vec; + } + + + public void resetWithNewEndValue( Vector2 endValue ) + { + _originalEndValue = endValue; + prepareForUse(); + } + +} diff --git a/Assets/Plugins/GoKit/properties/specificTypes/AnchoredPositionTweenProperty.cs.meta b/Assets/Plugins/GoKit/properties/specificTypes/AnchoredPositionTweenProperty.cs.meta new file mode 100644 index 0000000..d59f85a --- /dev/null +++ b/Assets/Plugins/GoKit/properties/specificTypes/AnchoredPositionTweenProperty.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 8cce0121362d1407cab2fc53b0c38e8a +timeCreated: 1429678139 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/GoKit/properties/specificTypes/OffsetTweenProperty.cs b/Assets/Plugins/GoKit/properties/specificTypes/OffsetTweenProperty.cs new file mode 100644 index 0000000..5517efb --- /dev/null +++ b/Assets/Plugins/GoKit/properties/specificTypes/OffsetTweenProperty.cs @@ -0,0 +1,76 @@ +using UnityEngine; +using System.Collections; + + +public class OffsetTweenProperty : AbstractTweenProperty +{ + protected bool _useMax; + + protected RectTransform _target; + + protected Vector2 _originalEndValue; + protected Vector2 _startValue; + protected Vector2 _endValue; + protected Vector2 _diffValue; + + public OffsetTweenProperty( Vector2 endValue, bool isRelative = false, bool useMax = false ) : base( isRelative ) + { + _originalEndValue = endValue; + _useMax = useMax; + } + + public override bool validateTarget( object target ) + { + return target is RectTransform; + } + + public override void prepareForUse() + { + _target = _ownerTween.target as RectTransform; + + _endValue = _originalEndValue; + + if( _ownerTween.isFrom ) + { + if( _useMax ) + { + _startValue = _isRelative ? _endValue + _target.offsetMax : _endValue; + _endValue = _target.offsetMax; + } + else + { + _startValue = _isRelative ? _endValue + _target.offsetMin : _endValue; + _endValue = _target.offsetMin; + } + } + else + { + _startValue = _useMax ? _target.offsetMax : _target.offsetMin; + } + + if( _isRelative && !_ownerTween.isFrom ) + _diffValue = _endValue; + else + _diffValue = _endValue - _startValue; + } + + + public override void tick( float totalElapsedTime ) + { + var easedTime = _easeFunction( totalElapsedTime, 0, 1, _ownerTween.duration ); + var vec = GoTweenUtils.unclampedVector2Lerp( _startValue, _diffValue, easedTime ); + + if( _useMax ) + _target.offsetMax = vec; + else + _target.offsetMin = vec; + } + + + public void resetWithNewEndValue( Vector2 endValue ) + { + _originalEndValue = endValue; + prepareForUse(); + } + +} diff --git a/Assets/Plugins/GoKit/properties/specificTypes/OffsetTweenProperty.cs.meta b/Assets/Plugins/GoKit/properties/specificTypes/OffsetTweenProperty.cs.meta new file mode 100644 index 0000000..3879f87 --- /dev/null +++ b/Assets/Plugins/GoKit/properties/specificTypes/OffsetTweenProperty.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: d04da800e36474cdfa7b6fad7529cc7e +timeCreated: 1429678113 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/GoKit/properties/specificTypes/PivotTweenProperty.cs b/Assets/Plugins/GoKit/properties/specificTypes/PivotTweenProperty.cs new file mode 100644 index 0000000..587ddcd --- /dev/null +++ b/Assets/Plugins/GoKit/properties/specificTypes/PivotTweenProperty.cs @@ -0,0 +1,62 @@ +using UnityEngine; +using System.Collections; + + +public class PivotTweenProperty : AbstractTweenProperty +{ + protected RectTransform _target; + + protected Vector2 _originalEndValue; + protected Vector2 _startValue; + protected Vector2 _endValue; + protected Vector2 _diffValue; + + public PivotTweenProperty( Vector2 endValue, bool isRelative = false) : base( isRelative ) + { + _originalEndValue = endValue; + } + + public override bool validateTarget( object target ) + { + return target is RectTransform; + } + + public override void prepareForUse() + { + _target = _ownerTween.target as RectTransform; + + _endValue = _originalEndValue; + + if( _ownerTween.isFrom ) + { + _startValue = _isRelative ? _endValue + _target.pivot : _endValue; + _endValue = _target.pivot; + } + else + { + _startValue = _target.pivot; + } + + if( _isRelative && !_ownerTween.isFrom ) + _diffValue = _endValue; + else + _diffValue = _endValue - _startValue; + } + + + public override void tick( float totalElapsedTime ) + { + var easedTime = _easeFunction( totalElapsedTime, 0, 1, _ownerTween.duration ); + var vec = GoTweenUtils.unclampedVector2Lerp( _startValue, _diffValue, easedTime ); + + _target.pivot = vec; + } + + + public void resetWithNewEndValue( Vector2 endValue ) + { + _originalEndValue = endValue; + prepareForUse(); + } + +} diff --git a/Assets/Plugins/GoKit/properties/specificTypes/PivotTweenProperty.cs.meta b/Assets/Plugins/GoKit/properties/specificTypes/PivotTweenProperty.cs.meta new file mode 100644 index 0000000..0c03703 --- /dev/null +++ b/Assets/Plugins/GoKit/properties/specificTypes/PivotTweenProperty.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: e80dda59e986948b3a06e66a0d5acf30 +timeCreated: 1429678106 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/GoKit/properties/specificTypes/SizeDeltaTweenProperty.cs b/Assets/Plugins/GoKit/properties/specificTypes/SizeDeltaTweenProperty.cs new file mode 100644 index 0000000..d243f11 --- /dev/null +++ b/Assets/Plugins/GoKit/properties/specificTypes/SizeDeltaTweenProperty.cs @@ -0,0 +1,62 @@ +using UnityEngine; +using System.Collections; + + +public class SizeDeltaTweenProperty : AbstractTweenProperty +{ + protected RectTransform _target; + + protected Vector2 _originalEndValue; + protected Vector2 _startValue; + protected Vector2 _endValue; + protected Vector2 _diffValue; + + public SizeDeltaTweenProperty( Vector2 endValue, bool isRelative = false) : base( isRelative ) + { + _originalEndValue = endValue; + } + + public override bool validateTarget( object target ) + { + return target is RectTransform; + } + + public override void prepareForUse() + { + _target = _ownerTween.target as RectTransform; + + _endValue = _originalEndValue; + + if( _ownerTween.isFrom ) + { + _startValue = _isRelative ? _endValue + _target.sizeDelta : _endValue; + _endValue = _target.sizeDelta; + } + else + { + _startValue = _target.sizeDelta; + } + + if( _isRelative && !_ownerTween.isFrom ) + _diffValue = _endValue; + else + _diffValue = _endValue - _startValue; + } + + + public override void tick( float totalElapsedTime ) + { + var easedTime = _easeFunction( totalElapsedTime, 0, 1, _ownerTween.duration ); + var vec = GoTweenUtils.unclampedVector2Lerp( _startValue, _diffValue, easedTime ); + + _target.sizeDelta = vec; + } + + + public void resetWithNewEndValue( Vector2 endValue ) + { + _originalEndValue = endValue; + prepareForUse(); + } + +} diff --git a/Assets/Plugins/GoKit/properties/specificTypes/SizeDeltaTweenProperty.cs.meta b/Assets/Plugins/GoKit/properties/specificTypes/SizeDeltaTweenProperty.cs.meta new file mode 100644 index 0000000..230de90 --- /dev/null +++ b/Assets/Plugins/GoKit/properties/specificTypes/SizeDeltaTweenProperty.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: a4c939632796b47569bc0aed99067a86 +timeCreated: 1429678097 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: