- Home /
How to attach a prefab to a script that is added dynamically
Hey,
I created a script that is added into my game is added to my player Game Object using the AddComponent() method. The thing is the script needs a prefab(ShockWave) and I'm not sure how to give it the prefab other than having to tell the script what it needs before runtime. I had always figured that I could just add the prefab into the field shown in the image below but that doesn't seem to work for me as it just comes up null.
Does anyone have a solution for this? Also was I correct in thinking I could add my prefab into this field?
Can you make the whole object a prefab with all script and other prefab already into it?
Your answer
Follow this Question
Related Questions
Acessing scripts in other game objects with prefabs, without using GameObject.Find 1 Answer
Assign a 'Transform' target to prefab by finding a 'GameObject' 1 Answer
Creating Prefab causes scripts to break, Copy/Paste Gameobject doesn't 0 Answers
Adding a script component through scripting 1 Answer
enable/disable specific components 3 Answers