Public static GameObject ConvertGameObject(GameObject go) The principle is to export the GameObject hierarchy to an FBX and then convert the exported FBX Model Prefab into a Prefab Variant while maintaining the components from the original hierarchy. You can convert a GameObject hierarchy to an FBX Prefab Variant using the API. ModelExporter.ExportObjects to export a single GameObject. You can use ModelExporter.ExportObject instead of ModelExporter.ExportObjects(filePath, objects, exportSettings)
Note: If you don't pass any export settings, Unity uses the default settings. String filePath = Path.Combine(Application.dataPath, 'MyGame.fbx') ĮxportModelOptions exportSettings = new ExportModelOptions() ĮxportSettings.ExportFormat = ExportFormat.Binary Public static void ExportGameObjects(Object objects) You can call the FBX Exporter from C# using methods found in the namespace, for example: using System.IO If you don't pass any export settings, Unity uses default export settings to export the GameObjects to the FBX file. To use custom export settings, you can create and pass an instance of ExportModelOptions class with modified settings. You can use the basic API by providing a single GameObject or a list of GameObjects. As a developer, you have access to the FBX Exporter from C# scripting.