- Home /
What process should I best use to properly create an updated copy of a Prefab?
This should be elementary. I have an existing prefab which contains about seven components, one of which is a script.
What I'd like to do is create for another scene, a very similar prefab, which contains a different script.
The process I'm using thus far fails in a very specific way. Using the editor, I place in the hierarchy a new game object which is an instance of the original prefab. I then alter its components to give the desired characteristics. I place the new script into the object, and assign a target transform which that new script requires. All is well up to this point.
Then I use Asset-> Create-> Prefab to make a new blank Prefab to which I want to assign the characteristics of the new object. I drag the object from Hierarchy into the Prefab. All components transfer correctly except for one item.
In the resulting prefab, the transform variable of the script is now "None", and of course, being a Prefab, it cannot be assigned manually.
I'm at wits' end. Suggestions welcome.
Answer by Bunny83 · Apr 10, 2011 at 08:52 PM
I'm not sure if i get that right... :D
So you have a script attached and this script has a public transform variable? What is assigned to that variable? or do you talk about the transform component of your prefab?
I also don't understand you last sentence. You can set variables of a prefab manually. Just select the prefab in the project view and edit it in the inspector. The only limitation is that you can only access the first two layers of the prefab.
The second way to "edit" a prefab is to drag it into a scene (create an instance) and change what you want. If you're done, just click the "apply" button at the top of the inspector to apply the changes to your prefab.
Maybe post a screenshot of your inspector to show what exactly you meant. Just edit your question if you want to change/add something.
Good luck
Sorry if I was unclear. The "transform" I mention is a public script variable.
I've tried your approach to create an instance and "Apply" the change in the inspector. Unfortunately, this also fails. The prefab was not changed, though of course the instance was.
Could you explain what you mean by "the first two layers" of the prefab? I've attempted to edit this prefab directly in the inspector to no avail.