Legacy Documentation: Version 2018.1 (Go to current version)
LanguageEnglish
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

Experimental: this API is experimental and might be changed or removed in the future.

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

public method SetMainObject(obj: Object): void;
public void SetMainObject(Object obj);

Parameters

objThe object to be set as the main object. This object must already be added with the AddObjectToAsset method.

Description

Sets the main object for import.

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 AddObjectToAsset. If this method is not called, then one of the objects added through AddObjectToAsset is arbitrarily promoted as the main object. If objects of type GameObject are added through AddObjectToAsset, then SetMainObject 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.

Did you find this page useful? Please give it a rating: