get rid of the temporary object (otherwise it stays over in scene) Template.GetComponent().sharedMesh = mesh ĮditorUtility.ReplacePrefab(template, prefab, ReplacePrefabOptions.ReplaceNameBased) assume that MeshFilter is already there. Mesh mesh = (Mesh)AssetDatabase.LoadAssetAtPath(prefabPath, typeof(Mesh)) ĪssetDatabase.AddObjectToAsset (mesh, prefabPath) Prefab = EditorUtility.CreateEmptyPrefab( prefabPath ) Object prefab = AssetDatabase.LoadAssetAtPath(prefabPath, typeof(GameObject)) this way links will persist when we regenerate the mesh GameObject template = (GameObject)EditorUtility.InstantiatePrefab(templatePrefab) Object templatePrefab = AssetDatabase.LoadAssetAtPath(modelTemplate, typeof(GameObject)) String modelTemplate = "Assets/Templates/Model.prefab" You can then either save your mesh into this prefab and assign it to `MeshFilter`'s `sharedMesh` or (useful if you want to generate multiple meshes into identical prefab) go something like: // All generated models will be structured after this template There is a method not involving generation of intermediate files: have a prefab template that looks almost ready and only misses a mesh.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |