IGUtils Class

Summary

Various utility methods used by InspectorGadgets.
Assembly
InspectorGadgets.dll
Namespace
InspectorGadgets
Base Types
  • Object
graph BT Type-->Base0["Object"] Type["IGUtils"] class Type type-node

Syntax

public static class IGUtils

Methods

Name Value Summary
AppendDeepToString(StringBuilder, IEnumerator, string) void
Each element returned by `enumerator` is appended to `text`.
static
AppendNameAndGenericArguments(StringBuilder, Type, bool, int) int
Appends the generic arguments of `type` (after skipping the specified number).
static
AppendNameCS(StringBuilder, MemberInfo, bool) StringBuilder
Appends the full name of a `member` as it would appear in C# code.

For example, passing this method info in as its own parameter would append "InspectorGadgets.IGUtils.AppendName".

Note that when `member` is a System.Type, this method calls InspectorGadgets.IGUtils.GetNameCS(System.Type,System.Boolean) instead.
static
AppendTransformPath(StringBuilder, Transform) void
Appends the full transform path to the target with slashes between the names of each of its parents, much like a file path.
static
CalculateLevenshteinDistance(string, string) int
Calculate the number of removals, inserts, and replacements needed to turn `a` into `b`.
static
ConvertCamelCaseToFriendly(string, bool) string
Adds spaces to `camelCase` before each uppercase letter.
static
ConvertCamelCaseToFriendly(StringBuilder, string, int, int, bool) void
Adds spaces to `camelCase` before each uppercase letter.
static
ConvertFieldNameToFriendly(string, bool) string
Adds spaces to `fieldName` before each uppercase letter and removes any underscores from the start.
static
CopyCurve(AnimationCurve) AnimationCurve
Creates a duplicate of the given `curve`.
static
DeepToString(IEnumerable) string
Returns a string containing the value of each element in `collection` (each on a new line).
static
DeepToString(IEnumerable, string) string
Returns a string containing the value of each element in `collection`.
static
DeepToString(IEnumerator) string
Returns a string containing the value of each element in `enumerator` (each on a new line).
static
DeepToString(IEnumerator, string) string
Returns a string containing the value of each element in `enumerator`.
static
EnforceHorizontalSymmetry(AnimationCurve) AnimationCurve
Ensures that the curve is horizontally symmetrical in relation to its existing start and end points.
static
ExtendMirrorred(AnimationCurve) AnimationCurve
Duplicates the curve past the end and mirrors the duplicated section. Returns the input curve so calls can be chained.
static
FindType(string, bool) Type
Calls System.Reflection.Assembly.GetType(System.String,System.Boolean,System.Boolean) on each currently loaded assembly until it finds a match then returns it.
static
FlipHorizontal(AnimationCurve) AnimationCurve
Reverses the curve so that it runs backwards over the same time range. Returns the input curve so calls can be chained.
static
FlipVertical(AnimationCurve) AnimationCurve
Reverses the curve so that its values are upside down within range. Returns the input curve so calls can be chained.
static
FlipWeightedMode(WeightedMode) WeightedMode
WeightedMode.Out becomes WeightedMode.In and vice versa.
static
ForEachType(Assembly, Action<Type>) void
Calls the specified `method` once for each type in the specified `assembly`.
static
ForEachTypeInDependantAssemblies(Assembly, Action<Type>) void
Calls the specified `method` once for each type in each loaded assembly that references the specified `assembly`.
static
GetAttributedFields<TAttribute>(Type, BindingFlags, List<TAttribute>, List<FieldInfo>) void
Get all fields with the specified attribute in `type`.
static
GetAttributedMethods<TAttribute>(Type, BindingFlags, List<TAttribute>, List<MethodInfo>) void
Get all methods with the specified attribute in `type`.
static
GetAttributedProperties<TAttribute>(Type, BindingFlags, List<TAttribute>, List<PropertyInfo>) void
Get all properties with the specified attribute in `type`.
static
GetBestMatch<T>(T[], string) T
Compares the name of each of the `objects` and returns the one that is closest to the `nameHint`.

See also: InspectorGadgets.IGUtils.CalculateLevenshteinDistance(System.String,System.String).
static
GetBestMatch<T>(T[], string, int) T
Compares the name of each of the `objects` and returns the one that is closest to the `nameHint`.

See also: InspectorGadgets.IGUtils.CalculateLevenshteinDistance(System.String,System.String).
static
GetComponentInHierarchy(GameObject, Type, string) Component
Finds a component of the specified `componentType` on the `gameObject` or any of its parents or children. If multiple components are found the one with a name closest to the `nameHint` is chosen.
static
GetCustomAttribute<T>(ICustomAttributeProvider, bool) T
Gets a single custom attribute of type T and casts it.
static
GetDerivedTypes(Type, bool) List<Type>
Gets all non-abstract types in the currently loaded assemblies which derive from the specified base type (including the base type itself if it is not abstract).
static
GetDerivedTypes(Type, ICollection<Type>, bool) void
Gets all non-abstract types in the currently loaded assemblies which derive from the specified base type (including the base type itself if it is not abstract).
static
GetDescription(AnimationCurve) string
Returns a string describing the start and end time and value of the `curve`.
static
GetMinMaxKeyValue(AnimationCurve, float, float) void
Gets the values of the lowest and highest keyframes.

Note that these will not necessarily be the exact bounds of the curve if the tangents cause it to continue further than the keyframes.
static
GetMinMaxKeyValue(Keyframe[], float, float) void
Gets the values of the lowest and highest keyframes.

Note that these will not necessarily be the exact bounds of the curve if the tangents cause it to continue further than the keyframes.
static
GetMinMaxValueEstimate(AnimationCurve, float, float, int) void
Estimates the highest and lowest values in the `curve`.
static
GetNameCS(MemberInfo, bool) string
Returns the full name of a `member` as it would appear in C# code.

For example, passing this method info in as its own parameter would return "InspectorGadgets.IGUtils.GetNameCS".

Note that when `member` is a System.Type, this method calls InspectorGadgets.IGUtils.GetNameCS(System.Type,System.Boolean) instead.
static
GetNameCS(Type, bool) string
Returns the name of a `type` as it would appear in C# code.

For example, typeof(List<float>).FullName would give you: System.Collections.Generic.List`1[[System.Single, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]

This method would instead return System.Collections.Generic.List<float> if `fullName` is true, or just List<float> if it is false.

Note that all returned values are stored in a dictionary to speed up repeated use.
static
GetOrAdd<TKey, TValue>(IDictionary<TKey, TValue>, TKey) TValue
If the specified `key` is present in the `dictionary`, its value is returned. Otherwise a new value is added to the `dictionary` and returned.
static
GetStartEndTime(AnimationCurve, float, float) void
Gets the time of the first and last keyframes.
static
GetStartEndTime(Keyframe[], float, float) void
Gets the time of the first and last keyframes.
static
GetStartEndValue(AnimationCurve, float, float) void
Gets the value of the first and last keyframes.
static
GetStartEndValue(Keyframe[], float, float) void
Gets the value of the first and last keyframes.
static
GetStartEndValueSorted(AnimationCurve, float, float) void
Gets the higher and lower value of the first and last keyframes.
static
GetStartEndValueSorted(Keyframe[], float, float) void
Gets the higher and lower value of the first and last keyframes.
static
GetTransformPath(Transform) string
Appends the full transform path to the target with slashes between the names of each of its parents, much like a file path.
static
IsNormalized(AnimationCurve) bool
Indicates whether the time and values both start at 0 and end at 1.
static
IsNormalized(Keyframe[]) bool
Indicates whether the time and values both start at 0 and end at 1.
static
IsNow(EditorState) bool
Returns true if the Unity Editor is currently in the specified `state`.
static
LinearRescale(float, float, float, float, float) float
Re-scales `value` from the old range (`oldMin` to `oldMax`) to the new range (`newMin` to `newMax`).
static
LinearRescaleTo01(float, float, float) float
Re-scales `value` from the old range (`oldMin` to `oldMax`) to the new range (0 to 1).
static
Normalize(AnimationCurve) AnimationCurve
Rescales the curve so the time and values both start at 0 and end at 1. Note that this does not modify any of the tangents so the shape of the curve may change. Returns the input curve so calls can be chained.
static
Normalize(Keyframe[]) Keyframe[]
Rescales the curve so the time and values both start at 0 and end at 1. Returns the input array so calls can be chained.
static
ProgressiveSearch(GameObject, Type, string) Component
Tries various search methods in the following order until it finds something: GameObject.GetComponent(Type), GameObject.GetComponentsInParent(Type, bool), GameObject.GetComponentsInChildren(Type, bool), Resources.FindObjectsOfTypeAll(Type).

In the first group where a component of the correct type is found, if multiple components were found the one with a name closest to the `nameHint` is chosen.
static
Set(Nullable<float>, float) void
If `source` is not null, `target` is given its value.
static
Set(Nullable<float>, float) float
If `source` is not null, return its value, otherwise return `target`.
static
SmoothTangents(AnimationCurve) AnimationCurve
Smooths the tangents of all keyframes. Returns the input curve so calls can be chained.
static
StableInsertionSort<T>(IList<T>) void
Sorts `list`, maintaining the order of any elements with an identical comparison (unlike the standard System.Collections.Generic.List`1.Sort method).
static
StableInsertionSort<T>(IList<T>, Comparison<T>) void
Sorts `list`, maintaining the order of any elements with an identical comparison (unlike the standard System.Collections.Generic.List`1.Sort(System.Comparison{`0}) method).
static
ToDisplayString(float) string
Returns the specified `value` as a string using the System.Globalization.CultureInfo.InvariantCulture.
static
ToDisplayString(Nullable<float>) string
Returns the specified `value` as a string, or "-" if it is null.
static
TruncateForLabel(string) string
Truncate the given string so it can be used in a GUI.Label. MaxLength = 16,382.
static