Playmaker Forum

Bug Reporting => PlayMaker Bug Reporting => Topic started by: delstrega on April 27, 2012, 06:36:54 AM

Title: iTweenStop after Application.LoadLevel() and FIX
Post by: delstrega on April 27, 2012, 06:36:54 AM
I get a "Missing Reference Exception" if I reload my Scene by using Application.LoadLevel()
and the iTweenStop-Action (with id) fires in one of my FSMs.
Everything works fine before I reload my scene.

It seems it doesn't like it if an "id" is supplied to iTweenStop after the Application.LoadLevel() since somehow the reference to the GameObject gets lost.

My fix:
instead of using
Code: [Select]
iTween.StopByName(id.Value);
in iTweenStop.cs in the Action Folder I use:

Code: [Select]
GameObject go = Fsm.GetOwnerDefaultTarget(gameObject);
if (go == null)
{
return;
}

iTween.StopByName(go,id.Value);

I hope that helps anyone with a similar problem.

Just for completeness, here's the ErrorLog:
MissingReferenceException: The object of type 'GameObject' has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.
UnityEngine.GameObject.GetComponents (System.Type type) (at C:/BuildAgent/work/b0bcff80449a48aa/Runtime/ExportGenerated/Editor/UnityEngineGameObject.cs:63)
iTween.StopByName (UnityEngine.GameObject target, System.String name) (at Assets/iTween/iTween.cs:6445)
iTween.StopByName (System.String name) (at Assets/iTween/iTween.cs:6393)
HutongGames.PlayMaker.Actions.iTweenStop.DoiTween () (at Assets/PlayMaker/Actions/iTween/iTweenStop.cs:56)
HutongGames.PlayMaker.Actions.iTweenStop.OnEnter () (at Assets/PlayMaker/Actions/iTween/iTweenStop.cs:30)
Title: Re: iTweenStop after Application.LoadLevel() and FIX
Post by: Alex Chouls on May 02, 2012, 08:24:09 PM
Thanks! I'll get the fix into the next update...