Version: 2021.3
言語: 日本語
public static string ExtractAsset (Object asset, string newPath);

パラメーター

asset The sub-asset to extract.
newPath The file path of the new Asset.

戻り値

string An empty string if Unity has successfully extracted the Asset, or an error message if not.

説明

インポートされたアセット (FBX ファイルなど) から抽出することにより、オブジェクト (マテリアルなど) から外部アセットを作成します。

NOTE: The feature is currently only available for materials embedded in model assets.

All file paths are relative to the project folder. For example: "Assets/Materials/myMaterial.mat".

Method throws ArgumentNullException when the Asset is null and ArgumentException when the file path is null or empty.

using UnityEngine;
using UnityEditor;

public class Extractor { public static void ExtractFromAsset(Object subAsset, string destinationPath) { string assetPath = AssetDatabase.GetAssetPath(subAsset);

AssetDatabase.ExtractAsset(subAsset, destinationPath);

AssetDatabase.WriteImportSettingsIfDirty(assetPath); AssetDatabase.ImportAsset(assetPath, ImportAssetOptions.ForceUpdate); } }