johnatm / itween

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

iTween.Count() inaccurate if Application.LoadLevel is called during an iTween #67

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
If, in the middle of an iTween, you call Application.LoadLevel, iTween's 
internal data structures will still show the active iTween, although the object 
it's attached to is now gone (unless you specified DontDestroyOnLoad).  This 
causes iTween.Count() to be inaccurate.

Original issue reported on code.google.com by e...@aptuslogic.com on 4 May 2011 at 5:24

GoogleCodeExporter commented 8 years ago
this can be corrected by adding:
    /// <summary>
    /// Destructor should be called before Application.LoadLevel()
    /// to ensure you can load the same level without problems later
    /// </summary>
    /*
     * this works by removing the references to the unused gameobjects which
     * allows then to be garbage collected 
     */
    public static void Destructor()
    {
        tweens = new ArrayList();//deletereferences right before destruction
    }

to the source code right after the Stop function.
and then in your code right before each time you call Application.LoadLevel();
add iTween.Destructor();
attached is a copy of the iTween code with this inserted.

Original comment by therealm...@gmail.com on 3 Mar 2013 at 6:14

Attachments:

GoogleCodeExporter commented 8 years ago
Genius thanks.  I noticed in my version of iTween I needed to use;

tweens = new List<Hashtable>();

but it seems to fix the problem just the same.

Original comment by TearsOfG...@gmail.com on 29 Aug 2013 at 10:53