Version: 2023.2
言語: 日本語
public static bool CopyAssets (string[] paths, string[] newPaths);

パラメーター

paths Filesystem paths of the source assets.
newPaths Filesystem paths of the new assets to create.

戻り値

bool Returns true if the copy operation is successful or false if part of the process fails.

説明

Duplicates assets in paths and stores them in newPaths.

All paths are relative to the project folder, for example: "Assetspathshello.png". paths and newPaths must contain the same number of items.

using UnityEngine;
using UnityEditor;

public class AssetDatabaseExamples : MonoBehaviour { [MenuItem("AssetDatabase/Duplicate Materials")] static void DuplicateMaterials() { string[] sourcePaths = new [] { "Assets/Materials/CarMaterial.mat", "Assets/Materials/TruckMaterial", "Assets/Materials/BoatMaterial" }; string[] targetPaths = new [] { "Assets/Duplicates/Materials/CarMaterial_Dup.mat", "Assets/Duplicates/Materials/TruckMaterial_Dup", "Assets/Duplicates/Materials/BoatMaterial_Dup" }; if(!AssetDatabase.CopyAssets(sourcePaths, targetPaths)) Debug.LogWarning($"Failed to copy assets"); } }

You cannot use this function during an import (either in process or from an asset worker), as it would result in new assets created in the middle of an import. Any errors and warnings from the copy operation are reported in the log and the console.

Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961