-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
… testing)
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ) ); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
|
||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
|
||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.