Version: 2017.3 (switch to 2017.4)
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.AddObjectToAsset

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 AddObjectToAsset(identifier: string, obj: Object): void;
public void AddObjectToAsset(string identifier, Object obj);
public method AddObjectToAsset(identifier: string, obj: Object, thumbnail: Texture2D): void;
public void AddObjectToAsset(string identifier, Object obj, Texture2D thumbnail);

Parameters

identifier A unique identifier associated to this object.
obj The Unity Object to add to the asset.
thumbnail An optional 2D texture to use as the tumbnail for this object.

Description

Adds an object to the result of the import operation.

Use this method to add objects to the resulting asset. AddObjectToAsset can be called multiple times if more than one unity object is the result of the import process. Note: You must make sure that your importer provides a unique identifier for each added object. You must also make sure that your code regenerates the same identifier each time the file is re-imported: indentifiers should be deterministic. This allows Unity to keep match previously imported objects with the newly created objects. The identifier only needs to be unique within the context of the Asset file and not globaly unique across your whole project.

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