Skip to content

Instantly share code, notes, and snippets.

public override string ToString()
{
const BindingFlags flags = BindingFlags.Public | BindingFlags.NonPublic |
BindingFlags.IgnoreCase | BindingFlags.Instance;
string result = $"{GetType().Name}:";
FieldInfo[] fields = GetType().GetFields(flags);
for (int i = 0; i < fields.Length; i++)
{
result += $"\n {fields[i].Name} = {fields[i].GetValue(this)}";
}
/// <summary>
/// Reflects in to Unity's internal drawers to find the cached
/// Reorderable list that will be used to draw the given property so
/// that it may be modified.
///
/// This depends on reflection and could break with any Unity update.
/// An alternative to using this would be to create your own
/// ReorderableList in a property drawer or custom editor.
/// </summary>
/// <param name="property">Array or List Property to look up.</param>