Version: Unity 6.7 Beta (6000.7)
LanguageEnglish
  • C#

AssetImportContext.SetMainObject

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Declaration

public void SetMainObject(Object obj);

Parameters

Parameter Description
obj The object to be set as the main object. It must be part of the imported asset: either added with the AddObjectToAsset method or produced by the importer.

Description

Sets the main object for import.

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

The main object takes the name of the asset file. A GameObject 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 AddObjectToAsset and pass the copy to SetMainObject.

Note: If this method is not called, then one of the objects added through AddObjectToAsset is arbitrarily promoted as the main object.