Unity 6.3
0 онлайн 0 гостей 3 в системе
Вход

Preset.excludedProperties

Declaration

public string[] excludedProperties;

Описание

Список свойств, которые следует игнорировать при применении Preset к объекту.

Задает список свойств или родительских свойств, которые будут игнорироваться при применении предварительной настройки к объекту.

using UnityEngine;
using UnityEditor.Presets;

static class PresetsExample { public static bool ApplyToWithExclusion(Preset preset, Transform target, string[] exclusion) { var current = preset.excludedProperties; preset.excludedProperties = exclusion; var success = preset.ApplyTo(target); preset.excludedProperties = current; return success; }

public static void ApplyTransformPresetWithoutPosition(Preset preset, Transform target) { if (ApplyToWithExclusion(preset, target, new[] { "m_LocalPosition" })) { Debug.Log("The Preset has been applied and the position hasn't changed"); } else { Debug.Log("The Preset was not applied"); } } }
using UnityEngine;
using UnityEditor.Presets;

static class PresetsExample { public static bool ApplyOnlyTheYPosition(Preset preset, Transform target) { var current = preset.excludedProperties; preset.excludedProperties = new[] { "m_LocalPosition.x", "m_LocalPosition.z" }; var success = preset.ApplyTo(target, new[] { "m_LocalPosition" }); preset.excludedProperties = current; return success; } }

Обратите внимание: Если все свойства Preset игнорируются, ApplyTo всегда возвращает false. Это также происходит, когда используется ApplyTo(Object, string[]) и указанный список свойств для применения все игнорируется.

using UnityEngine;
using UnityEditor.Presets;

static class PresetsExample { public static bool ApplyAlwaysReturnFalse(Preset preset, Transform target) { var current = preset.excludedProperties; preset.excludedProperties = new[] { "m_LocalPosition" }; var success = preset.ApplyTo(target, new[] { "m_LocalPosition" }); // always false because we try to apply only the ignored property. preset.excludedProperties = current; return success; } }