johnatm / itween

Automatically exported from code.google.com/p/itween
1 stars 2 forks source link

started+stopped tweens of inactive object accumulate in iTween::tweens hashtable #73

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1.
a script with the following -

    public GameObject target;

    // Use this for initialization
    void Start ()
    {   
        target.active = false;
    }

    // Update is called once per frame
    void Update ()
    {       
        iTween.MoveTo(target, Vector3.zero, 1.0f);
        iTween.Stop(target);        

        Debug.Log(iTween.Count(target));
    }
2.
two gameobjects, put the script in one, assign the other to be the target, then 
run

What is the expected output? What do you see instead?

note that the count continually goes up

What version of the product are you using? On what operating system?
2.0.44, osx 10.6

Please provide any additional information below.

the problem is that if the object isn't active, then the ID isn't set.  A quick 
hack/workaround I did is to add the following to the start of the Dispose() 
method:

                if (tweenArguments == null)
        {
            RetrieveArgs();
        }

-----

Don't know if this is something that's likely to happen for others, but I ran 
into it, and it took me a while to track down what was going wrong.

(also, I love iTween - thanks so much for it :) )

Original issue reported on code.google.com by analy...@gmail.com on 18 Jun 2011 at 3:23

GoogleCodeExporter commented 8 years ago
I was getting crashes in Awake->RetrieveArgs() as well for the same reason. In 
addition to the fix above, just destroying dead tweens seems to have fixed 
things

void RetrieveArgs(){
    foreach (Hashtable item in tweens) {
        if((GameObject)item["target"] == gameObject){
            tweenArguments=item;
            break;
        }
    }

    if (tweenArguments == null) 
    {
        Destroy(gameObject.GetComponent<iTween>());
        return;
    }

Original comment by FrankThe...@gmail.com on 19 Jun 2012 at 10:06