- Home /
I've attached a prefab to a script, but it still says the variable has not been assigned
Please see this screenshot: http://imgur.com/WnRq6 As you can see, I created an example prefab of a bomb, and attached it to the spawner script from an example project by the use of a new variable and dropping the prefab into the associated space on the inspector panel. However, when I run the script, the error (which can be seen in red on the bottom left) appears, claiming that the variable is unassigned. Any ideas?
Answer by always_beta · Aug 20, 2012 at 06:17 AM
Which GameObject has the script SpawnerScript attached? For example, GameObject A has SpawnerScript attached, then select GameObject A, in the Inspector, there will be something like 'Bomb Prefab None (Transform)' in the SpawnerScript component area, you should drag bombPrefab GameObject to this area and the error will be gone.
Your answer

Follow this Question
Related Questions
Creating a Prefab and Keeping Original Objects Script Information 0 Answers
Are there restrictions on assigning GameObjects to Prefab script variables? 3 Answers
Prefab not changing variable's values 2 Answers
Prefab problem, wont accept gameObject in var 3 Answers
Putting a variable of a child in the inspector for the parent 1 Answer