- Home /
Unity Itween error
How can this be solved, and what is the problem? error:
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) iTween.Stop (UnityEngine.GameObject target, System.String type) (at Assets/iTween/Plugins/iTween.cs:6436) 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 ()
found where the error is co$$anonymous$$g from, but i need help to solve it public static void Stop(GameObject target, string type){ Component[] tweens = target.GetComponents(typeof(iTween)); foreach (iTween item in tweens){ string targetType = item.type+item.method; targetType=targetType.Substring(0,type.Length); if(targetType.ToLower() == type.ToLower()){ item.Dispose(); } } }
Answer by Disastercake · Mar 22, 2013 at 03:39 AM
I believe this error is called when you destroy an object that is currently using an iTween. iTween isn't very friendly in this situation, and doesn't bother to check if the object has been destroyed. I think the only way you can really avoid this is to stop all iTweens on the object that you are destroying. It looks like you're using Playmaker, so check if there is a premade action that can remove all iTweens on the object. If there is not, you may want to post on the Playmaker forums about this so they can create one for you.
Answer by Chris12345 · Mar 22, 2013 at 02:08 PM
How can i check if this is null, still not working.
If you're still not working, I had to modify iTween itself to get $$anonymous$$e to work. I was not destroying the object the call was on, but StopByName (or in your case, Stop) was breaking anyways. I added a null check to that function in iTween and it fixed my problem.
Answer by hm_occupe · Nov 16, 2020 at 11:07 PM
if any one still having this problem in ITween this is my solution:
Edit the ITween.cs File (/Plugins/Pixelplacement/iTween/iTween.cs) At line 6150 public static void StopByName(GameObject target, string name){ //Add This Line `` if (target == null) return; Component[] tweens = target.GetComponents(); foreach (iTween item in tweens){ /string targetType = item.type+item.method; targetType=targetType.Substring(0,type.Length); if(targetType.ToLower() == type.ToLower()){ item.Dispose(); }/ if(item._name == name){ item.Dispose(); } } }
Your answer
Follow this Question
Related Questions
NGUI - Simulate a button press from script 3 Answers
itween add null checker 1 Answer
New UI Issues. 0 Answers
Playmaker: How to use transform.position in actions 2 Answers
iTween change loop type with Playmaker 0 Answers