This is a collection of project agnostic utilities and extensions for Unity.
They are implemented using PropertyDrawers for these specific types without a general editor that would inject itself everywhere. This makes this compatible and does not interfere with other custom editors.
Couple<T1, T2>
andTriple<T1, T2, T3>
tuplesMap<TKey, TValue>
dictionaryMinMax<T>
rangeMinMaxSlider
attribute to drawMinMax
as a sliderOptionalValue<T>
boolean enabled toggle wrapped around a valueInterfaceReference<T>
allows serializing objects that implement an interface
AutoSetup
attribute that tries to wire component references automatically
.With
,.Add
, and.Rotate
modifications, e.g.Vector3 v = transform.forward.With(y: 0f);
- Component wise
Mul
andDiv
SqrDist
semantic shorthandVector3.XY
,Vector3.XZ
, andVector2.X0Y
swizzling
Abs
,Round
,Max
,Clamp
, andRandom
that operate on a single vectorMin
andMax
that operate on two vectorsMax
andSum
that iterate over the components of a single vectorMinMax
that returns an ordered pair
ICollection.IsValidIndex
as guard against ArrayIndexOutOfBounds exceptionsIDictionary.GetOrCreate
KeyValuePair.Deconstruct
Overlap*
,Check*
, and*Cast
methods that take*Collider
as a parameter- Layer to LayerMask conversion
HasComponent
GetOrAddComponent
TryGetComponentInParent
TryGetComponentInChildren
GetComponentsInOnlyChildren
GetComponentsInOnlyCousins
SetPositionAndRotation
that takes aTransform
as parameter.
RevertIdenticalTransformOverrides
reverts unused overrides to local position and rotation to reduce prefab and scene file size and noise.HasIdenticalTransformOverrides
returns whether RevertIdenticalTransformOverrides has something to revert.
InputActionMap.SetEnabled
that callsEnable
orDisable
depending on the parameter.
SetActive
forVisualElement
that mimicsGameObject.SetActive
.
AspectRatioContainer
that maintains a configured aspect ratio.
- Each is a lightweight struct that contains a
position
and arotation
field. Similar to Unity'sTransform
but without scale, parent, children, component, and other overhead. - They contain the same data, but are semantically different, as they encode the space in which they are to be interpreted.
- Various
TransformXXX
andInverseTransformXXX
methods are provided to convert objects between spaces. WorldPose
andLocalPose
can be implicitly created fromTransform
. When implicit conversions from other custom types are added,WorldPose
andLocalPose
can be used as general purpose parameter that reduce the amount of overloads needed.
EnumValues
iterator, e.g.foreach(var value in Utils.EnumValues<SomeEnum>())
ReturnValueAndLogError
utility for lean switch expressions
Vector4
field in one line (likeVector3
andQuaternion
fields).- Prevent clipping of MinMaxSlider Handles at edges by added padding.