I am trying to create a prefab variant of a prefab that it is inside a package, but the option Create is disabled.
I think this is because you can not write inside the package folder, but this prefab would be located in the asset folder, not inside the package folder.
Is there any workarround to create a variant from a prefab inside packages?
Thank you
I created the variant by code and apparently it is working just fine
GameObject objSource =(GameObject)PrefabUtility.InstantiatePrefab(source);
GameObject obj = PrefabUtility.SaveAsPrefabAsset(objSource, variantAssetPath);
But I still would like to know if this is allowed, meaning to have a prefab variant of a prefab in the package folder, or it is disabled by design for some reason
Interesting. I think what you’re doing is technically legal but you do expose yourself to the shape of that prefab changing “magically” via a future Package update, rendering your variant damaged in some way.
You actually can copy / paste the prefab out of the Packages area into your Assets area. It kinda comes down to your philosophy of explicit derivation vs implicit derivation I suppose.
I was able to do this indirectly in editor:
- Drag-and-drop the package prefab into a scene
- Drag-and-drop the instance in the scene into an Assets folder
This creates a variant of the original prefab.