- Home /
I keep getting Asset path error with PrefabUtility.SaveAsPrefabAsset
Hi I'm trying to make a function that makes objects in hierarchy into prefabs. but I keep getting this error.
I tried "", "Assets/", "Assets", and etc but all of them keep giving me this path error. I'm not sure whats wrong.
Answer by Bonfire-Boy · Feb 08, 2019 at 12:31 PM
Prefabs have to be saved with the extension ".prefab".
The old utilities used to have a more explicit error message in this situation, odd that they've changed it to this unhelpful one.
You might want to think about giving them different names, too.
How do you add that extension though? I've been unable to find out how, all sources explaning this issue just say i need to add .prefab to something, but not where and how.
The extension as in the filename extension.
You pass a file path to the SaveAsPrefabAsset
function... that path needs to end with ".prefab".
The problem in the question is that they're passing "Assets/Temporary". If they passed "Assets/Temporay.prefab" it should work (as far as the invalid path error is concerned - they'd still have the issue that they're potentially saving multiple prefabs using the same path).
Your answer
![](https://koobas.hobune.stream/wayback/20220612191345im_/https://answers.unity.com/themes/thub/images/avi.jpg)