using System;
using System.Collections.Generic;
using System.Reflection;
using UnityEngine;
namespace UnityEditor.XR.Interaction.Toolkit.Utilities
{
///
/// Utility class for Inspector classes in the XR Interaction Toolkit.
///
public static class XRInteractionEditorUtility
{
///
/// Returns a list containing the names of all fields
/// defined in the Editor (including derived types).
///
/// The instance to reflect.
/// Returns a list of strings with property names.
///
public static List GetDerivedSerializedPropertyNames(Editor editor)
{
if (editor == null)
throw new ArgumentNullException(nameof(editor));
var fields = editor.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
var propertyNames = new List { "m_Script" };
foreach (var field in fields)
{
var value = field.GetValue(editor);
if (value is SerializedProperty serializedProperty)
{
propertyNames.Add(serializedProperty.name);
}
}
return propertyNames;
}
}
}