Version: 2020.1
言語: 日本語
Experimental: this API is experimental and might be changed or removed in the future.

ScriptedImporter

class in UnityEditor.Experimental.AssetImporters

/

継承:AssetImporter

マニュアルに切り替える

説明

Abstract base class for custom Asset importers.

Scripted importers are scripts that are associated with specific file extensions. They are invoked by Unity's Asset pipeline to convert the contents of associated files into Assets.

Use the ScriptedImporterAttribute class to register custom importers with the Asset pipeline.

using UnityEngine;
using UnityEditor.Experimental.AssetImporters;
using System.IO;

[ScriptedImporter(1, "cube")] public class CubeImporter : ScriptedImporter { public float m_Scale = 1;

public override void OnImportAsset(AssetImportContext ctx) { var cube = GameObject.CreatePrimitive(PrimitiveType.Cube); var position = JsonUtility.FromJson<Vector3>(File.ReadAllText(ctx.assetPath));

cube.transform.position = position; cube.transform.localScale = new Vector3(m_Scale, m_Scale, m_Scale);

// 'cube' is a a GameObject and will be automatically converted into a Prefab // (Only the 'Main Asset' is elligible to become a Prefab.) ctx.AddObjectToAsset("main obj", cube); ctx.SetMainObject(cube);

var material = new Material(Shader.Find("Standard")); material.color = Color.red;

// Assets must be assigned a unique identifier string consistent across imports ctx.AddObjectToAsset("my Material", material);

// Assets that are not passed into the context as import outputs must be destroyed var tempMesh = new Mesh(); DestroyImmediate(tempMesh); } }

Public 関数

OnImportAssetThis method must by overriden by the derived class and is called by the Asset pipeline to import files.
SupportsRemappedAssetTypeOverride this method if your ScriptedImporter supports remapping specific asset types.

メッセージ

GatherDependenciesFromSourceFileA static callback that you can implement to set up artifact dependencies to other Assets, and optimize the order your assets are imported.
OnValidateThis function is called when the importer is loaded or a value is changed in the Inspector.
Resetデフォルト値にリセットします

継承メンバー

変数

assetBundleNameアセットバンドルの名前の取得や設定ができます。
assetBundleVariantアセットバンドルバリアントの取得や設定ができます。
assetPathアセットのパス(読み取り専用)
importSettingsMissingThe value is true when no meta file is provided with the imported asset.
userDataユーザーが自由に設定/取得できる文字列
hideFlagsShould the object be hidden, saved with the Scene or modifiable by the user?
nameオブジェクト名

Public 関数

AddRemapMap a sub-asset from an imported asset (such as an FBX file) to an external Asset of the same type.
GetExternalObjectMapGets a copy of the external object map used by the AssetImporter.
RemoveRemapRemoves an item from the map of external objects.
SaveAndReimportアセットインポーターがダーティであれば、アセットインポーターの設定を保存します。
SetAssetBundleNameAndVariantアセットバンドル名とアセットバンドルバリアントを設定します。
GetInstanceIDオブジェクトのインスタンス ID を返します
ToStringReturns the name of the object.

Static 関数

GetAtPathアセットのパスから AssetImporter を取得します
DestroyRemoves a GameObject, component or asset.
DestroyImmediateDestroys the object obj immediately. You are strongly recommended to use Destroy instead.
DontDestroyOnLoadDo not destroy the target Object when loading a new Scene.
FindObjectOfTypeタイプ type から最初に見つけたアクティブのオブジェクトを返します
FindObjectsOfTypeGets a list of all loaded objects of Type type.
Instantiateoriginal のオブジェクトをクローンします

Operator

boolオブジェクトが存在するかどうか
operator !=二つのオブジェクトが異なるオブジェクトを参照しているか比較します
operator ==2つのオブジェクト参照が同じオブジェクトを参照しているか比較します。