x


create prefab in code from mesh made from scratch

Hello, So, I have a player fbx that was imported with some clothing items. Simply copying the shirt in the editor does not leave me with a copy that I can freely use...the bones will still be bound to the original fbx\gameobject. To overcome this, I make a copy of the object in code by taking the verts, bones, uvs, etc of the original and make a skinned mesh game object. This way, the new mesh is no longer bound to the original object, and I can apply this new object to another game object (that has the same bone structure) So far, everything works as intended. However, I dont want to do this operation every time I want to access a certain shirt...I want to make prefabs out of these newly copied items. So, in an editor script, I have code like this:

UnityEngine.Object prefab = EditorUtility.CreateEmptyPrefab("Assets\tempPrefab\" + newGameObject.name + ".prefab");

EditorUtility.ReplacePrefab(newGameObject, prefab); AssetDatabase.Refresh();

However, the prefabs that are made from this code do NOT have the mesh data. It has the name and bone structure, but no mesh data. The copied game objects I'm using to make the prefab have all the info I need...but making a prefab out of it in code or by hand in the editor(drag and drop) leaves me with blank items. any ideas?

more ▼

asked Oct 31 '11 at 05:40 PM

kablammyman gravatar image

kablammyman
52 2 3 6

(comments are locked)
10|3000 characters needed characters left

0 answers: sort oldest
Be the first one to answer this question
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x1256
x17

asked: Oct 31 '11 at 05:40 PM

Seen: 708 times

Last Updated: Oct 31 '11 at 05:43 PM