Preset

class in UnityEditor.Presets

/

Inherits from:Object

Switch to Manual

Description

一个预设包含一个对象的默认值。

Preset 类包含创建对象时所用的对象类型以及含此对象的每个已序列化属性/值对的列表。 此类可用于在 Editor 中存储任何已序列化对象的信息,并可将这些信息重新应用到此对象或同类型的其他任何对象。 此外,还可以使用 .preset 扩展名将预设另存为资源。

using UnityEditor;
using UnityEditor.Presets;
using UnityEngine;

public static class PresetUsageExample { // This method uses a Preset to copy the serialized values from the source to the target and return true if the copy succeed. public static bool CopyObjectSerialization(Object source, Object target) { Preset preset = new Preset(source); return preset.ApplyTo(target); }

// This method creates a Preset from a given Object and save it as an asset in the project. public static void CreatePresetAsset(Object source, string name) { Preset preset = new Preset(source); AssetDatabase.CreateAsset(preset, "Assets/" + name + ".preset"); } }

Variables

PropertyModifications返回此预设所拥有的 PropertyModification 数组的副本。

Constructors

Preset从给定的对象中构造新的预设。

Public Functions

ApplyTo将此预设应用到目标对象。
CanBeAppliedTo如果此预设可应用到目标对象,则返回 true。
DataEqualsDetermines if the target object has the same serialized values as the Preset.
GetTargetFullTypeName返回此预设目标完整类型的可读字符串,包括命名空间。
GetTargetTypeName返回此预设目标类型的可读字符串。
IsValid如果此预设的预设类型有效,则返回 true。
UpdateProperties使用给定对象的值来更新此预设的属性。给定对象的类型必须与此预设的类型相匹配。

Static Functions

GetDefaultForObject返回分配给相同对象类型的当前默认预设。如果没有匹配的默认值,则返回 null。
GetDefaultForPreset返回分配给相同预设类型的当前默认预设。如果没有匹配的默认值,则返回 null。
IsObjectExcludedFromDefaultPresets如果此对象无法拥有默认预设,则返回 true。
IsObjectExcludedFromPresets如果此对象在预设系统中不可用,则返回 true。
IsPresetExcludedFromDefaultPresets如果此预设无法设置为默认值,则返回 true。
RemoveFromDefault删除项目中具有默认值的预设。
SetAsDefault针对预设在项目中的目标类型将其设置为默认值。

Inherited members

Variables

hideFlagsShould the object be hidden, saved with the Scene or modifiable by the user?
name对象的名称。

Public Functions

GetInstanceID返回对象的实例 ID。
ToString返回 GameObject 的名称。

Static Functions

Destroy删除 GameObject、组件或资源。
DestroyImmediate立即销毁对象 /obj/。强烈建议您改用 Destroy。
DontDestroyOnLoadDo not destroy the target Object when loading a new Scene.
FindObjectOfType返回第一个类型为 type 的已加载的激活对象。
FindObjectsOfType返回所有类型为 type 的已加载的激活对象的列表。
Instantiate克隆 original 对象并返回克隆对象。

Operators

bool该对象是否存在?
operator !=比较两个对象是否引用不同的对象。
operator ==比较两个对象引用,判断它们是否引用同一个对象。