Version: 1.7
LanguageEnglish
  • C#

InstantAssetTable.MergeFrom

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 MergeFrom(InstantAssetTable sourceTable);

Parameters

sourceTable The source table whose contents will be merged into this table.

Description

Merges all asset entries and their metadata from another InstantAssetTable into this table.

This operation adds new assets and overwrites existing entries with those from the source table. Commonly used to combine multiple asset tables or update this table with additional assets.

using UnityEngine;
using System.IO;

public class MergeExample : MonoBehaviour { public InstantAssetTable mainTable; public string sourceTablePath = "Assets/StreamingAssets/additional_assets"; void Start() { // Load another asset table InstantAssetTable sourceTable = InstantAsset.ReadAssetTable(sourceTablePath) as InstantAssetTable; if (sourceTable != null) { // Merge source table into main table mainTable.MergeFrom(sourceTable); Debug.Log("Tables merged successfully!"); Debug.Log($"Main table now contains {mainTable.GetAllAssetsPath().Length} assets"); // Clean up InstantAsset.UnloadAssetTable(sourceTable); } else { Debug.LogError("Failed to load source asset table"); } } }