Comments (6)
@sathyarajshetigar there will a small allocation each time you call that method. If you are calling it every frame definitely cache the tween. If you are only calling it every so often no need to bother caching it.
from gokit.
GoKit is pretty extensible so you can add in pretty much anything you want the fits into the idea of tweening or even just having a tick method called. For example, below is a quick and dirty implementation of an Action tween that can be called like this:
Go.to( cube, 4, new GoTweenConfig() )
.addTweenProperty( new ActionProperty( val => Debug.Log( val ) ) );
public class ActionProperty : AbstractTweenProperty
{
System.Action<float> _setter;
float _startValue;
float _endValue;
public ActionProperty( System.Action<float> setter, float startValue = 0, float endValue = 1 )
{
_setter = setter;
_startValue = startValue;
_endValue = endValue;
}
public override void prepareForUse()
{}
public override void tick( float totalElapsedTime )
{
var easedValue = _easeFunction( totalElapsedTime, _startValue, _endValue, _ownerTween.duration );
_setter( easedValue );
}
}
from gokit.
Hi,
I tried using the code and it does not work as expected. Here is the code. All I get is the start value
public class GoFloatProperty : AbstractTweenProperty
{
private Action _setter;
private float _startValue;
private float _endValue;
public GoFloatProperty(float startValue, float endValue, Action<float> setter)
{
_setter = setter;
_startValue = startValue;
_endValue = endValue;
}
public override void prepareForUse()
{
}
public override void tick(float totalElapsedTime)
{
float easedValue = _easeFunction(totalElapsedTime, _startValue, _endValue, _ownerTween.duration);
_setter(easedValue);
UnityEngine.Debug.Log("Tick " + easedValue + " totalElapsedTime " + totalElapsedTime +
" _ownerTween.duration " + _ownerTween.duration + " _startValue " + _startValue + " _endValue " + _endValue);
}
}
//and used it like this
Go.to(this, 1, new GoTweenConfig().addTweenProperty(new GoFloatProperty(100.0f, 0.0f, val => Debug.Log(val))));
//It prints only 100,100,100.........
Did I miss anything?
from gokit.
Try out the ActionTweenProperty class that I just pushed to the repo. It will work for both forwards and backwards tweens.
from gokit.
Awesome. That did work. Thanks a ton
from gokit.
Quick question. Does AbstractTweenProperty instance allocate memory?
I use the following code every time "ShowToast" Method is called
Go.to(this, TWEENSPEED, new GoTweenConfig().addTweenProperty(new FloatActionTweenProperty(1, 0, val =>
{
toastScreenCanvasGroup.alpha = val;
}))).setOnCompleteHandler((bt) =>
{
toastScreen.SetActive(false);
});
Is it fine this way or should I assign it a variable and use it to play the next time? Is there any performance difference?
from gokit.
Related Issues (20)
- GoDummyPathEditor "Shift Path to Start at Origin" seems to be incorrect
- AbstractGoTween.goTo does not update rotation HOT 1
- Android streaming GoSpline asset bug? HOT 2
- Built-in support for inserting functions into GoTweenCollections HOT 6
- Docs: link not working anymore (README.md) HOT 3
- Doesn't compile for Windows Phone 8 HOT 1
- What do you think about rearranging this repo so it could be a submodule or a subtree? HOT 5
- GoTween Incompatible with IL2CPP scripting backend HOT 14
- [Question] Player Camera on Path HOT 1
- Non functioning Tween when reusing a GoTween instance with modified TweenProperties HOT 5
- Canceling / destroying a tween collection HOT 4
- Changing the speed/during of a GoTween/GoTweenChain while it is playing HOT 2
- Is there a way to save all running tweens? HOT 1
- Need help with playBackwards() HOT 3
- How to check if Go has no animation running HOT 2
- [FEATURE REQUEST] ECS Support HOT 2
- Tweening Rotations Shortest Distance HOT 1
- Is there a way to queue Tweens by GoKit itself?
- Documentation installation (via github?) HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gokit.