- Home /
Cloned/Instantiated GameObject's Losing Public Variables When Created?
Hello, I currently have a game object set as a prefab being cloned repeatedly, however, it seems that each time it is cloned the new game object loses the assets associated with the public variables in the script attached. Can someone help by explaining why this occurs and potential how to fix it? Thanks in advance.
Answer by victorbisaev · Jan 31, 2018 at 09:18 PM
Please inspect your code as Unity documentation says "When you clone a GameObject or Component, all child objects and components will also be cloned with their properties set like those of the original object." and it actually works as expected.
Maybe you can give more details on how it looks like that "the new game object loses the assets associated with the public variables in the script attached" so then it could give the idea what has happened?
Alright so after some tinkering I think I got it to work. It appears that maybe that I had actually set an incorrect variable in the prefab being cloned. Thank you for your quick response!
Your answer
Follow this Question
Related Questions
Particle Shaders not rendering if Instantiated 0 Answers
Unable to attach script to GameObject prefab at runtime 0 Answers
Can't assign variable to prefab, or apply changes to prefab. 1 Answer
What does "Couldn't find matching instance in prefab" mean? 2 Answers
GameObject is already being activated or desactivated 2 Answers