Version: 2022.1
public void SetMainObject (Object obj);

参数

obj 要设置为主要对象的对象。此对象必须已经使用 AddObjectToAsset 方法添加。

描述

设置导入的主要对象。

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.

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