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()

Scene Management

-

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

  1. 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.

Comments (2)

  1. 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);

  2. Airmouse

    Mar 23, 2019 05:40

    Same in 2019, break Unity automation and is makeing gamebuilding a time consuming nightmare.

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.