Version: 2020.1
언어: 한국어
Experimental: this API is experimental and might be changed or removed in the future.

CollectImportedDependenciesAttributeConstructor

매뉴얼로 전환
public CollectImportedDependenciesAttribute (Type importerType, uint version);

파라미터

importerType The type of the importer for which the getter is called by the AssetDatabase.
version The version of the imported dependencies getter.

설명

Use the CollectImportedDependencies attribute to declare getters for imported dependencies.

It is recommended to always increment the version number of the callback whenever the script is changed. This forces assets imported with lower version numbers to be re-imported.

This example shows how you can declare a dependency between two prefabs imported by the ModelImporter and use them in an AssetPostprocessor.

using UnityEditor;
using UnityEditor.Experimental.AssetImporters;
using UnityEngine;

public class ProceduralParentPostprocessor : AssetPostprocessor { private const string s_DependentPath = "Assets/ProceduralPrefab.fbx"; private const string s_DependencyPath = "Assets/DependencyPrefab.fbx";

[CollectImportedDependencies(typeof(ModelImporter), 1)] public static string[] CollectImportedDependenciesForModelImporter(string assetPath) { if (assetPath.Equals(s_DependentPath)) return new[] { s_DependencyPath };

return null; }

void OnPostprocessMeshHierarchy(GameObject root) { if (root.name == "ProceduralPrefabRoot") { // Add a new child game object var go = AssetDatabase.LoadMainAssetAtPath(s_DependencyPath) as GameObject; Object.Instantiate(go, root.transform, true); } } }

Note: The attribute supports only native importer types with AssetPostprocessor callbacks: ModelImporter, TextureImporter, AudioImporter, and SpeedTreeImporter.

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