I'm saving instances of tweens that need to be reused often, with minor TweenProperty changes. Here's what my code looks like:
// declaration as a field of my class
private GoTween _myTween;
// setup
var config = new GoTweenConfig().setEaseType(GoEaseType.CircOut).startPaused();
_myTween = new GoTween(_myTarget, 1.0f, config);
_myTween.autoRemoveOnComplete = false;
Go.addTween(_myTween);
// use
int newValue = Random(0, 100); // same tween, but a different value each time
_myTween.clearTweenProperties(); // get rid of old properties from last use
_myTween.addTweenProperty(new IntTweenProperty("MyIntProperty", newValue));
_myTween.goToAndPlay(0.0f); // play from the start
This works the first time the tween is used, but after that, the value set by the tween is always 0 instead of newValue.
From debugging, it looks like the newly added TweenProperty is never getting its prepareForUse() method called, which normally happens in GoTween's onInit(). I think either prepareForUse() should be called on new properties added via addTweenProperty() if the GoTween's _didInit is true, or there should be exposed a Reset() method to set the _didInit field back to false on the GoTween, so it will properly call prepareForUse() on all TweenProperties.
I'll experiment with these fixes and submit a pull request once I have a proper fix, but it would be nice to hear from an author with more knowledge of the code as to what the best solution is.
I'm saving instances of tweens that need to be reused often, with minor TweenProperty changes. Here's what my code looks like:
This works the first time the tween is used, but after that, the value set by the tween is always 0 instead of
newValue.From debugging, it looks like the newly added TweenProperty is never getting its
prepareForUse()method called, which normally happens in GoTween'sonInit(). I think eitherprepareForUse()should be called on new properties added viaaddTweenProperty()if the GoTween's_didInitis true, or there should be exposed aReset()method to set the_didInitfield back to false on the GoTween, so it will properly callprepareForUse()on all TweenProperties.I'll experiment with these fixes and submit a pull request once I have a proper fix, but it would be nice to hear from an author with more knowledge of the code as to what the best solution is.