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
-
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
- “[Worker0] Could not generate preview image“ error when opening macOS native plugin in the Inspector with Architecture to build for set to ARM 64-bit
- [iOS] Application.absoluteURL is empty on Awake/Start when opening via deep link with Splash Screen disabled
- Crash on MemoryManager::Deallocate when rapidly calling Addressables.LoadAssetAsync
- Crash on physx::shdfnd::atomicIncrement when adjusting values on a character controller component after entering Play mode in Prefab edit mode
- [Rendering Debugger] [NewInputSystem] Debug Overlays in Play mode throws InvalidOperationException when using New Input System
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.