- Home /
itween add null checker
how can i add null to this script to see if a object has been destroyed?
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 sdgd · Mar 22, 2013 at 02:28 PM
BTW your code was very bad written so I had to re edit it to even see what's going on
next time I'll leave the down vote
I removed it as you did help me help your self
public static void Stop(GameObject target, string type){
if (target == null){
return;
}
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();
}
}
}
all you need to enter is
after the start of your function
if (target == null){
return;
}
else you would wrap whole your inside of function in to:
if (target != null){
// your code you need
}
Thank you so much i have been working on this for days, you just saved my life:)
ok i tried the code and it stopped giving me the error, but it is messing up my itween functions on some objects that do not get deleted.
I solved this error and everything is working great.:)
Your answer
Follow this Question
Related Questions
Unity Itween error 3 Answers
Null Ref Error with Playmaker and iTween 1 Answer
Why do edits no longer appear on this site? 2 Answers
Set rotation in script like editor? 1 Answer