- Home /
How to check if object is "this" object?
I'm looping through some objects with Javascript:
for(block in blocks){
//script
}
I've notice that the object running the script is included in "blocks", so I was wondering how to check if an object is the exact instance of the object running the script.
Answer by Kiwasi · Jul 19, 2014 at 09:12 PM
if (block.gameObject == gameObject)
// Or if this is running from a block component
if (block == this)
Lol xD
Edit : Congrat's on the 5k karma milestone @Bored$$anonymous$$ormon
@Lo0Nuhti$$anonymous$$ Thanks. Except I've already managed to delete one comment when I tried to convert it to an answer. Didn't think it would be that hard to figure out.
'With great power comes great responsibility'
It might have been a site bug that did it. @robertbu tried to convert one of my comments to an answer a week or so ago and it got consumed by The Nothing also.
Your answer
Follow this Question
Related Questions
Can someone help me fix my Javascript for Flickering Light? 6 Answers
help converting javascript this function 1 Answer
Setting Scroll View Width GUILayout 1 Answer
Java Script command list 3 Answers
Pairing and GUITexture with a Timer? 1 Answer