Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: Netjera on August 17, 2012, 01:23:31 PM

Title: Using "Destroy Component" on Mesh Renderer causes GameObject destroy error?[SOL]
Post by: Netjera on August 17, 2012, 01:23:31 PM
I'm not sure if this is a bug, or if this is something I'm doing wrong, so I thought I'd ask.

I'm using "Destroy Component: Mesh Renderer" on a game object, so that it appears invisible, but isn't destroyed from the scene.  I want to add the Mesh Renderer in using "Add Component: Mesh Renderer" at a later time.  However, the compiler appears to be throwing this error after removing the mesh renderer:

Code: [Select]
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/d9c061b1c154f5ae/Runtime/ExportGenerated/Editor/UnityEngineGameObject.cs:63)
iTween.Stop (UnityEngine.GameObject target, System.String type) (at Assets/iTween/iTween.cs:6427)
HutongGames.PlayMaker.Actions.iTweenFsmAction.OnExitiTween (HutongGames.PlayMaker.FsmOwnerDefault anOwner) (at Assets/PlayMaker/Actions/iTween/iTweenFsmAction.cs:64)
HutongGames.PlayMaker.Actions.iTweenMoveTo.OnExit () (at Assets/PlayMaker/Actions/iTween/iTweenMoveTo.cs:110)
HutongGames.PlayMaker.FsmState.OnExit ()
HutongGames.PlayMaker.Fsm.ExitState (HutongGames.PlayMaker.FsmState state)
HutongGames.PlayMaker.Fsm.Stop ()
HutongGames.PlayMaker.Fsm.OnDisable ()
PlayMakerFSM.OnDisable ()


I've double-checked and am not destroying anything else.  Further, the later addition of the mesh renderer using "Add Component: Mesh Renderer" does not appear to work.

Can anyone tell me what's going on, and if I'm doing something wrong?  I've checked the reference, already, and it wasn't any help.  Thanks!
Title: Re: Using "Destroy Component" on Mesh Renderer causes GameObject destroy error?
Post by: mental.breakdance on January 06, 2013, 08:16:53 PM
I see this is an old post, but I'm getting something similar. Fairly simple MOR (assuming game object creation/destruction order is the same for other people)


It looks as though either iTweenFsmAction::OnExitiTween needs to null check "go" or iTween needs to do it further down the line.
I've just added a null check, but haven't really used Playmaker/iTween enough to know if this is a proper fix to the problem.
Title: Re: Using "Destroy Component" on Mesh Renderer causes GameObject destroy error?
Post by: jeanfabre on January 07, 2013, 02:14:48 AM
hi,

 Yes that was the issue, sometimes you need to make sure the gameObject is not null, to prevent errors.

bye,

 Jean