playMaker

Author Topic: Using "Destroy Component" on Mesh Renderer causes GameObject destroy error?[SOL]  (Read 5254 times)

Netjera

  • Playmaker Newbie
  • *
  • Posts: 41
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!
« Last Edit: January 07, 2013, 02:15:15 AM by jeanfabre »

mental.breakdance

  • Playmaker Newbie
  • *
  • Posts: 8
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)

  • Create an object with a FSM on it. (I just added one to the main camera)
  • Add a cube to the scene
  • In the FSM create an iTween action (e.g. rotate to)
  • set the game Object on the action to "Specify Game Object" and pick the cube
  • not sure if you need to set a vector rotation but that's what I did
  • start then stop the game
  • notice the error message "MissingReferenceException: The object of type 'GameObject' has been destroyed but you are still trying to access it." when stopping

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.
« Last Edit: January 06, 2013, 09:09:24 PM by mental.breakdance »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
hi,

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

bye,

 Jean