Search Issue Tracker
By Design
Votes
0
Found in
2018.3.0a6
2018.3.0f2
2019.1.0a1
2019.2.0a1
Issue ID
1114273
Regression
No
ArgumentException is thrown when trying to create a Prefab out of a imported model asset using PrefabUtility.SaveAsPrefabAsset()
Reproduction steps:
1. Open the project from "CreatePrefabFromModelBug.zip"
2. Right click on the "Model" asset inside Project window and click -> Reimport
Expected: New prefab is created from the reimported model
Actual: "ArgumentException: Can't save persistent object as a Prefab asset" is thrown and logged in the console
Reproduces on: 2018.3.6f1, 2019.1.0b3, 2019.2.0a5
Note:
PrefabUtility.SaveAsPrefabAsset was introduced in 2018.3.0a6
Comments (2)
-
Airmouse
Mar 23, 2019 06:00
Turns out it was because I was trying to save the .fbx directly as a prefab. Instead I needed to first instantiate it, then I could save it:
var SceneObject = Instantiate(modelAsset);
PrefabUtility.SaveAsPrefabAsset (SceneObject, destinationPath);
DestroyImmediate (SceneObject); -
Airmouse
Mar 23, 2019 05:40
Same in 2019, break Unity automation and is makeing gamebuilding a time consuming nightmare.
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- URP Realtime reflection probes do not update when RenderProbe() is being called once per second
- Addressable terrain shader variants are stripped from the Player
- [iOS] Debug.Log() appears as <private> in Console app
- UI stays in the background when it is disabled in simulator
- A wrong log file is attached when project is launched with a "-logFile" command line argument
Resolution Note:
The creation of the prefab out of the model in postprocessor requires a little bit more code: You need to instantiate your model first, then save as prefab asset and destroy the instance.