coolboy1 / dotween

Automatically exported from code.google.com/p/dotween
1 stars 0 forks source link

A sequence can't be populated with elements when using a reference to it. #24

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1.
Sequence mySequence;
bool initalised;

void Start()
    {
        mySequence = DOTween.Sequence();
    }

 void BuildSequence()
    {
        // Add a movement tween at the beginning
        mySequence.Append(transform.DOMoveX(10f, 2f).SetEase(Ease.InOutQuad));

        // Add a rotation tween as soon as the previous one is finished
        mySequence.Append(transform.DORotate(new Vector3(0, 180, 0), 1));

        // Delay the whole Sequence by 1 second
        mySequence.PrependInterval(1);

        // Add a second to the end
        mySequence.AppendInterval(1);

        // Insert a scale tween for the whole duration of the Sequence
        mySequence.Insert(0, transform.DOScale(new Vector3(3, 3, 3), mySequence.Duration()));

        Debug.Log("Sequence Duration:" + mySequence.Duration());
    }

void Update()
    {

        if (Input.GetMouseButton(0) && initalised == false)
        {
            initalised = true;
            BuildSequence();
        }
}

2.
The duration of the sequence is 0 if you have created a reference to it in the 
Start method but have attempted to populate the sequence in a different method.

What is the expected output? What do you see instead?
A sequence can be populated with tweens and callbacks after a reference to it 
has been created.

What version of the product are you using? On what operating system?
Unity 5.0.0b18 (64-bit)
Windoze 7

Please provide any additional information below.
DOTween rocks!

Original issue reported on code.google.com by jared.lu...@gmail.com on 13 Feb 2015 at 12:41

GoogleCodeExporter commented 8 years ago
Found a fix...
Add:
mySequence.Pause();
after the sequence is created.

Original comment by jared.lu...@gmail.com on 13 Feb 2015 at 12:50

GoogleCodeExporter commented 8 years ago
Hi Jared,

thanks for the nice words :)

You got it correctly with Pause. Sequences are "locked" as soon as they start, 
meaning the frame after they're created, so pausing them prevents them to play 
and they are not initialized/locked immediately.

Cheers

Original comment by daniele....@gmail.com on 13 Feb 2015 at 1:04