Cannot apply particle effect to rocket prefab

When I drag a particle effect from the hierarchy to the serialized property of the rocket ship, it gets applied and it works in the game. When I try to apply the changes to the prefab, however, I get the following message: “Cannot apply reference to object in scene - Cannot apply reference to object in scene”.

Alternatively, if I drag and assign the particle effect prefab into the serialized property, it gets assigned but does not show when I run the game.

What am I doing wrong?

Hi Pedro7,

Welcome to our community! :slight_smile:

Objects in your scene get created and destroyed during runtime. For this reason, your prefabs in your Assets folder are not allowed to reference them.

Did this clear it up for you?

Thanks for the quick reply. I still can’t get the particle system assigned to the prefab via dropping it on the rocketship serialized property. In the video the teacher is definitely dragging the object reference from the scene hierarchy window and dropping it on to the serialized property of the rocketship scene object, and then applying it to the prefab, and that works in the video, but I get the error message I mentioned in my original post.

If the correct way would be to drag the particle asset from the Project assets folder and not from the scene hierarchy, how do I activate it in code? - The code from the video does not work if I drop the particle asset into the serialized property of the rocketship instead of dropping the particle object from the scene hierarchy.

This is not a big deal, but it does mean that I have to add the particle effects to the Level 2 scene hierarchy separately otherwise the rocketship instance in Level 2 won’t have the particle effects to be activated by the code. I’m just wondering how I can roll the particle effects into the prefab like in the video, so I don’t have to repeat this work for each level/scene. This could be a Unity version issue, I wonder? I’m using the current latest 2019.3.9f1.

If your Rocket prefab has got children, you could assign the child of the prefab to the parent prefab. Double click on the prefab to get into the prefab edit mode. When you are done, you can drag the parent prefab into your Hierarchy. That works.

If you already have a Rocket in your Hierarchy, you need to drag its own child with the Particle System assigned to its exposed field. Then click on Overrides > Apply all. That’ll add a child to the prefab if the Rocket from your Hierarchy is still linked to the prefab.

If nothing helps, complete your rocket in the Hierarchy. Delete the Rocket prefab, and drag the rocket from your Hierarchy into your Assets folder.

Using Overrides > Apply all worked! It’s all good now. Thank you.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms