Hi,
I have a really strange problem. I’m working on an arkanoid clone. I have created a prefab for a block and instantiate them using it.
Now I added a script to the prefab. But for some reason the clones created with Instantiate do not have the script. I do the same thing for the ball and the paddle. The ball and paddle clones have the scripts that are attached to the prefabs, but the block clones don’t.
Now if I will drag the block prefab to the scene, the resulting object will have the script, but if I drag it while “Play” is pressed the object won’t have the script.
Any idea what might be causing this strange behavior?
Perhaps there is some code that’s destroying that component. If you drag the prefab out while the game is running but paused, you see the script on it… and then when you unpause, it disappears? If so, that sure sounds to me like some code is explicitly destroying it.
I found the issue. Kind of. There was one “if” in the script that was causing this issue. If I comment it out, I can see the script.
Visual studio was not showing any errors in the script. I think it’s a logical issue in the script. Wish unity would somehow let us know about things like that, throw an error or something.
Wasted a few hours trying to figure out what was the issue.