# SetMainObject(Object)

> Sets the main object for import.

## Definition

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

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

### Parameters

**** (\[Object]\(/engine/6000.6/script-reference/unityengine/object)): The object to be set as the main object. This object must already be added with the [AssetImportContext.AddObjectToAsset](/engine/6000.6/script-reference/unityeditor/assetimporters/assetimportcontext/addobjecttoasset.md) method.

### Remarks

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

Note: Before invoking this method, the object that is passed as the argument must first be added with [AssetImportContext.AddObjectToAsset](/engine/6000.6/script-reference/unityeditor/assetimporters/assetimportcontext/addobjecttoasset.md). If this method is not called, then one of the objects added through [AssetImportContext.AddObjectToAsset](/engine/6000.6/script-reference/unityeditor/assetimporters/assetimportcontext/addobjecttoasset.md) is arbitrarily promoted as the main object. If objects of type [GameObject](/engine/6000.6/script-reference/unityengine/gameobject.md) are added through [AssetImportContext.AddObjectToAsset](/engine/6000.6/script-reference/unityeditor/assetimporters/assetimportcontext/addobjecttoasset.md), then [AssetImportContext.SetMainObject](/engine/6000.6/script-reference/unityeditor/assetimporters/assetimportcontext/setmainobject.md) must refer to one of these objects. Passing a different type of object results in the selection being ignored and an arbitrary GameObjects is promoted as the main object.

Note: This method returns an error when used in an AssetPostprocessor because the Importer sets the main object later in the import process.
