PrefabUtility.CreatePrefab() results in "not a valid asset file name" error?

I’m trying to create a new prefab in an editor script based on a pre-existing GameObject in the scene by using UnityEditor.PrefabUtility.CreatePrefab(pathStr, obj). The specific path I’m using for testing is Assets\TreeGen\Tests\Baked Trees\Tree1\Tree1Original.prefab; as far as I can tell based on Google searches, this is the correct way to pass in the prefab name (i.e. using a path starting in “Assets”, and including the “.prefab” at the end). However, I get an error:

‘Assets\TreeGen\Tests\Baked Trees\Tree1\Tree1Original.prefab’ is not a valid asset file name.

UnityEditor.PrefabUtility:CreatePrefab(String, GameObject)

CurveMeshEditor:BakeToFile(String) (at Assets/TreeGen/Editor/CurveMeshEditor.cs:124)

CurveMeshEditor:OnInspectorGUI() (at Assets/TreeGen/Editor/CurveMeshEditor.cs:78)

UnityEditor.DockArea:OnGUI()

Am I using this method wrong?

Looks like the problem is related to using “/” vs "". Try replacing with “/” and see if it works, looks like it did for me. Good luck!

Ye, me to :confused: and i found even your Redit post and my path has only 82 chars, so we will have to just wait for bugfix.

Im just curious, how did you do the workaround to this whole problem that doesn’t involve prefabs ?