Editor : dynamic asset creation and prefabs, best practice ?


I am creating an editor extension (a voxel editor for creating models).

There is a lot of dynamic assets creation involved (texture, mesh, material, data)

I’ve managed to overcome most of the problems working with the editor using a lot of googling, and it is basically working, but I don’t know if I handle asset creation the right way.

Model creation :

	- create data asset (scriptable object stored in a .asset file)
	- create mesh asset (mesh object stored in a .asset file)
	- create texture asset (texture .png)
	- create material asset (material .mat)

Start editing model :

	- duplicate existing data asset (new .asset file)
	- duplicate existing mesh asset (new .asset file)
	- duplicate existing texture asset (new .png file)
	- duplicate existing material asset (new .mat file)

Now, I guess you are asking : why duplicate assets every time ?

If the user creates a prefab with the voxel model, and edit an instance of the prefab, we need separate data or all prefab instances will be updated, even if the user never click “Apply”.

Of course because of that, every time we start editing a model a lot of slow IO takes place. Also a lot of unused asset files might be generated.

Is there a better way to handle dynamic asset file creation / prefab generation ?

I know prefab need physical asset files to retain the link when the prefab is created, but gameobjects do not. Is there a way to generate the files only when the prefab is created by the user ?

Thanks a lot for your time

I have my answer : my voxel data should not be considered as a an attribute of the prefab but as the model as a whole. Instead, I will provide a “Clone” button to duplicate all the model assets.