Version: 1.8
LanguageEnglish
  • C#

InstantAssetTable.Subtract

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

Parameters

sourceTable The source table containing assets to be removed from this table.

Description

Removes all asset entries and their metadata that exist in another InstantAssetTable from this table.

This operation effectively filters out assets that are present in the source table, leaving only unique entries. Useful for creating differential asset tables or removing specific assets.

using UnityEngine;
using System.IO;

public class SubtractExample : MonoBehaviour { public InstantAssetTable fullTable; public string baseTablePath = "Assets/StreamingAssets/base_assets"; void Start() { // Load the base asset table InstantAssetTable baseTable = InstantAsset.ReadAssetTable(baseTablePath) as InstantAssetTable; if (baseTable != null) { // Get initial count int initialCount = fullTable.GetAllAssetsPath().Length; // Subtract base table from full table (removes common assets) fullTable.Subtract(baseTable); int finalCount = fullTable.GetAllAssetsPath().Length; Debug.Log($"Subtracted {initialCount - finalCount} common assets"); Debug.Log($"Remaining unique assets: {finalCount}"); // Clean up InstantAsset.UnloadAssetTable(baseTable); } else { Debug.LogError("Failed to load base asset table"); } } }