/* Create a preform */ async Task creatorPrefab(string filePath) {
// This relative path is best modified to the current script path , For specific methods, please refer to another article to get script path GameObject _newPrefab = AssetDatabase.
LoadAssetAtPath<GameObject>(
"Assets/Editor/XLua/EditorWindow/Function2/ModleDialog.prefab"); _newPrefab =
GameObject.Instantiate(_newPrefab);// Instantiate it first await Task.Delay(System.TimeSpan.
FromSeconds(0.2)); Delay for a while // Save to filePath Under the path Object createObj = PrefabUtility.
SaveAsPrefabAsset(_newPrefab,filePath);// Using absolute paths will warn you , Try to turn to relative path GameObject.
DestroyImmediate(_newPrefab);// Delete instanced objects immediately }
Examples
/* Formwork preform */ Task _prefabtask = creatorPrefab(@"Assets/Resources/Prefabs/UI/"+
enableName+"/"+enableName+".prefab");
Technology