Version: 2021.3

Preset.GetAllDefaultTypes

切换到手册
public static PresetType[] GetAllDefaultTypes ();

描述

Returns all the PresetType that have at least one DefaultPreset entry in the default Presets list.

Use this method to gather all existing DefaultPreset and all Preset used as default in a project.

using UnityEditor;
using UnityEditor.Presets;
using UnityEngine;

public static class PresetExample { [MenuItem("Presets Example/Log All Default Preset")] public static void LogDefaultPreset() { var defaultTypes = Preset.GetAllDefaultTypes(); foreach (var defaultType in defaultTypes) { var defaults = Preset.GetDefaultPresetsForType(defaultType); foreach (var defaultPreset in defaults) { Debug.Log($"Default - Filter:{defaultPreset.filter}, Enabled:{defaultPreset.enabled}, Name:{defaultPreset.preset.name}", defaultPreset.preset); } } } }