# SetMainObject(Object)

> Sets the main object for import.

## Definition

* **Type:** Method
* **Namespace:** [UnityEditor.AssetImporters](/engine/6000.7/script-reference/unityeditor/assetimporters.md)
* **Assembly:** UnityEditor.CoreModule

```csharp
public void SetMainObject(Object obj)
```

### Parameters

**** (\[Object]\(/engine/6000.7/script-reference/unityengine/object)): The object to be set as the main object. It must be part of the imported asset: either added with the [AssetImportContext.AddObjectToAsset](/engine/6000.7/script-reference/unityeditor/assetimporters/assetimportcontext/addobjecttoasset.md) method or produced by the importer.

### Remarks

Use this method to specify the main object in the asset file.

The main object takes the name of the asset file. A [GameObject](/engine/6000.7/script-reference/unityengine/gameobject.md) that has a parent in the imported hierarchy cannot become the main object; Unity ignores such a nomination and logs a warning. To use part of a hierarchy as the main object, add a copy of it with [AssetImportContext.AddObjectToAsset](/engine/6000.7/script-reference/unityeditor/assetimporters/assetimportcontext/addobjecttoasset.md) and pass the copy to `SetMainObject`.

Note: If this method is not called, then one of the objects added through [AssetImportContext.AddObjectToAsset](/engine/6000.7/script-reference/unityeditor/assetimporters/assetimportcontext/addobjecttoasset.md) is arbitrarily promoted as the main object.
