[Solved] Unity won't let me drag the Enemy prefab into the Enemy Prefab

Having a strange issue where the inspector won’t allow me to attach my enemy prefab. I can only attach it assuming it’s already in the hierarchy which obviously isn’t the correct solution given that we want it as a prefab.

I should also add that I attempted to run Unity in both standard and administrator modes.

Hi @in-Just,

Can you select it instead of dragging it? e.g. click on the little circle to the right of the Enemy Prefab field, this will open a browsing window from which you could select it.

Try that and see if it works.

If not, can you record a video of your desktop so we can see what you’re doing and what’s happening?

prefabs

If you drag the Enemy from the hierarchy to the Prefab folder or Assets folder it will become a prefab. He does in the video at 2.26. If the enemy is a blue cube it is a prefab. If it is a picture like the green or red spaceship then it is not on mine.

Does that work now? @in-JUST

This is along the lines of what I ended up doing a while ago.

Great

i have exactly the same problem i cant do it

i have tried rob point of view before i cant acess my my prefabs from that little circle

Hi @joaogracio,

Have you already created the prefabs? e.g. from having a game object in Hierarchy and then dragging it into the Assets/Prefabs folder in the Project View?

i get it… praticly…

but academcly speeking why would i need to take my sprite o hierarchy to them make a prefab to them
make it a gameobject attribute???

1 Like

The workflow I believe is one where by you create your game object(s), configure them as you would want, this is done using the Hierarchy so that you can see them actually in the scene, giving you the ability to interact/view etc.

The practice of creating a prefab is really just a way of storing a kind of cookie cutter, so that you can make one or more clones of the same game object(s) later.

You could of course just right-click and choose “Create Prefab” but you would still need to drag some form of game object into that in order for it to be of much use.

The point here is that you are designing the thing that you want to turn into the cookie cutter. Once that step is done, you now have the cookie cutter to use to make many cookies… or, in this case, enemy space ships.

For example, I could create an enemy spaceship here for you, package it up and send it to you, you could then drop it straight into that exposed GameObject field and use what I had created. Your code would still run as it should. You could then switch back very easily to your own enemy spaceship prefab by dragging yours into the exposed property.

The prefabs are just for storying game objects with their specific components and properties.

Hope this is of help.


See also;

Unity - Manual : Prefabs

it make sense to me tanks

1 Like

Privacy & Terms