Version: 2022.3
언어: 한국어

AssetDatabase.GetDefaultImporter

매뉴얼로 전환
public static Type GetDefaultImporter (string path);

파라미터

path Asset path.

반환

Type Importer type.

설명

Returns the Default Importer associated with the asset located at the supplied path. When no Importer override is set, then the default importer is used. See Also: AssetDatabase.GetImporterOverride, AssetDatabase.ClearImporterOverride.

using System;
using UnityEngine;
using UnityEditor;
using UnityEditor.AssetImporters;

public class AssetDatabaseExamples : MonoBehaviour { [MenuItem("AssetDatabase/Available Importer Types for cube")] static void AvailableImporterTypeCube() { var path = "Assets/CompanionCube.fbx"; AssetDatabase.GetDefaultImporter(path); // returns ModelImporter. AssetDatabase.GetImporterOverride(path); // returns null because no Override Importer is set. AssetDatabase.GetAvailableImporters(path); // returns [CubeImporter]. AssetDatabase.SetImporterOverride<CubeImporter>(path); // sets CubeImporter as Override Importer. AssetDatabase.ClearImporterOverride(path); // removes the Override Importer. AssetDatabase.GetImporterOverride(path); // returns null because no Override Importer is set. }

//This is Example Importer for cube [ScriptedImporter(1, new []{"cube" }, new[] { "fbx" })] public class CubeImporter : ScriptedImporter { public override void OnImportAsset(AssetImportContext ctx) { var cube = GameObject.CreatePrimitive(PrimitiveType.Cube); cube.transform.position = new Vector3(0, 0, 0); // 'cube' is a GameObject and will be automatically converted into a prefab ctx.AddObjectToAsset("main obj", cube); ctx.SetMainObject(cube); } } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961