How to store a generic tween?
« on: June 11, 2016, 09:26:26 PM »
Hello there

How are you doing?

I have a vertical layout group that consists of the letters in the alphabet.

Users can do either of these two options:
- vertically scroll letters
- use the center letter. Depending on whether they drag the letter left/right it sends a message to the following method by passing a letter index (a List) so a letter is moved and centered in the vertical layout group.

Code: [Select]
public void LetterInterval (int value) {
float offset = value * LetterHeight;
float offsetMin = _rectHeight + offset;
float offsetMax = offset;

// Debug.Log(offsetMin);
// Debug.Log(offsetMax);

DOTween.To(() => _rectForVerticalLayoutGroup.offsetMin, x => _rectForVerticalLayoutGroup.offsetMin = x, new Vector2(0f, offsetMin), _CENTERING_TIME).SetEase(Ease.InOutCubic);
DOTween.To(() => _rectForVerticalLayoutGroup.offsetMax, x => _rectForVerticalLayoutGroup.offsetMax = x, new Vector2(0f, offsetMax), _CENTERING_TIME).SetEase(Ease.InOutCubic);
}

PROBLEM is that moving the vertical layout group kind of spikes the physics 2d in the profile, but more importantly going from A back to Z causes a serious expensive on an iPhone 6 Plus. It jumps from 23% to 50%. See the video:

https://www.dropbox.com/s/q8rdh3zann5tal4/video%20of%20tweening.mov?dl=0

My solution is to store the Sequence, but I am unsure how you store a lambda, given the final value is not always known.

Hope that makes sense.

Thanks
German