Unity extensions
June 19, 2026 ยท View on GitHub
Extension methods for Unity types in FronkonGames.GameWork.Foundation. Import the namespace and call methods on the extended type.
See also: System extensions.
GameObjects and components
| Class | Highlights |
|---|---|
| GameObjectExtensions | SafeDestroy, DestroyAfter, GetAllChildren, ChangeMaterial, SetLayer |
| ComponentExtensions | Component lookup and batch helpers |
| MonoBehaviourExtensions | SafeStartCoroutine, RestartCoroutine, DontDestroyOnLoad, ResolveComponentFromChildrenIfNull |
| UnityObjectExtensions | UnityEngine.Object utilities |
| TryGetExtensions | Safe TryGetComponent patterns |
using FronkonGames.GameWork.Foundation;
projectile.SafeDestroy();
enemy.DestroyAfter(3.0f);
Transforms
TransformExtensions, the largest Unity extension file.
| Area | Examples |
|---|---|
| Hierarchy | GetPath, FindChildRecursive, DestroyChildren, GetAllChildren |
| Position | SetX/Y/Z, SetLocalXYZ, TranslateXYZ, ResetWorld/Local |
| Scale | SetScaleXYZ, ScaleByXYZ, FlipX/Y/Z, ResetScale |
| Rotation | RotateAroundX/Y/Z, SetRotationY, ResetRotation |
| RectTransform | ResetRect, ExpandFullscreen (via RectTransformExtensions) |
player.transform.SetY(groundHeight);
turretHead.SetLocalRotationY(yawAngle);
Vectors and quaternions
| Class | Highlights |
|---|---|
| Vector2Extensions | Rotate, 2D math helpers |
| Vector3Extensions | 3D vector utilities |
| Vector4Extensions | 4D vector helpers |
| Vector2IntExtensions | Integer grid coordinates |
| Vector3IntExtensions | 3D integer vectors |
| VectorConversionExtensions | Cast between vector types |
| QuaternionExtensions | NearlyEquals, AngleTo, IsIdentity, Normalized |
| QuaternionConversionExtensions | Quaternion/type conversions |
| Matrix4x4Extensions | DecomposeTRS, extract position, rotation, scale |
Vector2 aim = direction.Rotate(Mathf.PI * 0.25f);
matrix.DecomposeTRS(out Vector3 pos, out Quaternion rot, out Vector3 scale);
Colors, sprites, and textures
| Class | Highlights |
|---|---|
| ColorExtensions | HSV, hex, HDR (GetHdrIntensity, AdjustHdrIntensity, AtHdrIntensity), tint/shade/tone |
| Color32Extensions | CreateTexture, equality checks |
| SpriteExtensions | GetPixels32, GetRect, IsFullyTransparent |
| Texture2DExtensions | Texture manipulation |
| ImageExtensions | UI Image helpers |
| MaterialExtensions | Material property shortcuts |
Color hdr = baseColor.AtHdrIntensity(2.0f);
Color parsed = "#FF8800".FromHex();
Physics and spatial
| Class | Highlights |
|---|---|
| ColliderExtensions | Collider bounds and queries |
| RigidbodyExtensions | Rigidbody velocity and forces |
| RaycastHitExtensions | Hit info helpers |
| LayerMaskExtensions | IsInLayerMask, layer utilities |
| BoundsExtensions | Bounds math |
| BoundsIntExtensions | Integer bounds |
| CameraExtensions | Camera frustum and screen helpers |
UI and layout
| Class | Highlights |
|---|---|
| RectTransformExtensions | Margins, size, ExpandFullscreen, ToWorldBounds |
| RectExtensions | WithRoundedCoordinates, CutVertically, AddHorizontalPadding, AlignMiddleVertically |
| RectLineIntersectionHelper | GetLineIntersections, line/rect crossing points |
| ButtonExtensions | UI button helpers |
| ScrollRectExtensions | Scroll view utilities |
| CanvasGroupExtensions | SetActive with alpha and interactable control |
Rect padded = panelRect.AddHorizontalPadding(8.0f);
LineIntersectionResult hit = bounds.GetLineIntersections(segmentStart, segmentEnd);
Audio
| Class | Highlights |
|---|---|
| AudioExtensions | ToDecibel, ToLinear, amplitude/decibel conversion |
| AudioSourceExtensions | SetPitch, SetVolume with random ranges |
| AudioMixerExtensions | Mixer parameter helpers |
float db = linearAmplitude.ToDecibel();
float linear = (-6.0f).ToLinear();
Animation, particles, and rendering
| Class | Highlights |
|---|---|
| AnimatorExtensions | Animator state helpers |
| ParticleSystemExtensions | Particle control |
| RendererExtensions | Renderer material access |
| MeshExtensions | Mesh data utilities |
| MeshFilterExtensions | MeshFilter helpers |
Async and events
| Class | Highlights |
|---|---|
| AsyncOperationExtensions | AsyncOperation await helpers |
| AwaitableExtensions | Unity 6 Awaitable โ Task conversion |
| UnityEventExtensions | Event wiring utilities |
Collections and flags
| Class | Highlights |
|---|---|
| CollectionExtensions | AddIfMissing |
| ReadOnlyCollectionExtensions | IndexOf on IReadOnlyCollection<T> |
| EnumFlagsExtensions | Flags enum helpers |
Misc
| Class | Highlights |
|---|---|
| Tailwind | Tailwind-style spacing and sizing shortcuts for UI layout |
Tests
Unit tests live under Test/Extensions.