This module is part of the Unity Essentials ecosystem and follows the same lightweight, editor-first approach. Unity Essentials is a lightweight, modular set of editor utilities and helpers that streamline Unity development. It focuses on clean, dependency-free tools that work well together.
All utilities are under the UnityEssentials namespace.
using UnityEssentials;
Install the Unity Essentials entry package via Unity's Package Manager, then install modules from the Tools menu.
-
Add the entry package (via Git URL)
- Window → Package Manager
- "+" → "Add package from git URL…"
- Paste:
https://github.com/EggyStudio/UnityEssentials.git
-
Install or update Unity Essentials packages
- Tools → Install & Update UnityEssentials
- Install all or select individual modules; run again anytime to update
Quick overview: Handy, zero‑dependency extension methods for common Unity tasks: camera dynamic resolution, safe destroy helpers, component access, string formatting, vector conversions/parsing, math/remap, interpolation, and audio dB mapping.
A grab‑bag of well‑scoped helpers you can call from anywhere. Toggle HDRP dynamic resolution on a Camera, safely destroy GameObjects and their children (Editor vs Play aware), get or add components, transform snake_case/camelCase into Title Case, convert and parse vectors, remap and round values, ease between ranges, and convert UI volume levels to decibels for mixers.
- Camera helpers
camera.SetDynamicResolution(bool allow)– togglesCamera.allowDynamicResolutionand, when HDRP is present,HDAdditionalCameraData.allowDynamicResolution(cached per camera)
- Destroy helpers
transform.DestroyAllChildren()– removes all child GameObjects (usesDestroyImmediatein Editor,Destroyin Play)transform.DestroyAllChildren<T>()/component.DestroyAllChildren<T>()– destroys all GameObjects that haveTin this hierarchygameObject.Destroy()– destroys all children first, then the GameObject (Editor‑safe)
- Component helpers
GetOrAddComponent<T>(this GameObject|Component)– returns existingTor adds one
- String helpers
"some_valueOrName".Format()→"Some Value Or Name"(underscores to spaces, camel case split, Title Case)
- Vector conversions
(double,double).ToVector2(),(double,double,double).ToVector3()Vector2Int.ToVector2()→Vector3(x, y, 0);Vector3Int.ToVector3(),Vector3.ToVector3Int(),Vector2.ToVector2Int()
- Vector parsing
"1920x1080".ExtractVector2FromString('x')→Vector2(1920, 1080)"1,2,3".ExtractVector3FromString(',')→Vector3(1, 2, 3)
- Math utilities
value.Remap(srcMin, srcMax, dstMin, dstMax)– linear remap (no clamp)vector.Round(decimalPlaces)– round each componentvectorA.Divide(vectorB)– component‑wise division
- Interpolation helpers
new Vector2(min, max).Lerp(t)/new Vector2Int(min, max).Lerp(t)– linear interpolation within a rangenew Vector2(min, max).Slerp(t, power)– eased Lerp (t^power), not geometric spherical lerp
- Audio utility
intVolume.ToDecibelLevel()– maps 0→‑80 dB, 100→0 dB, 200→+20 dB via a perceptual curve
- Unity Editor 6000.0+
- Optional: HDRP (for
SetDynamicResolutionto also affectHDAdditionalCameraData) - No other module dependencies required
Tip: You can use these in both Editor and Play Mode. Destroy helpers automatically choose DestroyImmediate in the Editor to avoid orphaned objects.
Camera dynamic resolution (HDRP‑aware)
Camera.main.SetDynamicResolution(true);
Destroy children and objects
// Remove all children of this transform transform.DestroyAllChildren(); // Remove all GameObjects in hierarchy that have a Light component transform.DestroyAllChildren<Light>(); // Safely destroy a whole object (including its children) myObject.Destroy();
Get or add component
var audio = gameObject.GetOrAddComponent<AudioSource>();
String formatting
"player_healthMax".Format(); // "Player Health Max" "MainMenuButton".Format(); // "Main Menu Button"
Vector conversions and parsing
var v2 = (12.5, 3.75).ToVector2(); var v3 = (1.0, 2.0, 3.0).ToVector3(); var v3From2Int = new Vector2Int(5, 9).ToVector2(); // Vector3(5, 9, 0) var res = "1920x1080".ExtractVector2FromString('x'); var pos = "1,2,3".ExtractVector3FromString(',');
Math and interpolation
float mapped = 0.25f.Remap(0f, 1f, 10f, 20f); // 12.5 var rounded = new Vector3(1.2345f, 6.789f, 0.12f).Round(2); var divided = new Vector3(10, 20, 30).Divide(new Vector3(2, 4, 5)); // (5, 5, 6) float t = 0.3f; float v = new Vector2(0, 100).Lerp(t); // 30 float eased = new Vector2(0, 100).Slerp(t, 2); // 9 (quadratic ease‑in)
Audio (UI slider 0‑200 → dB)
int uiVolume = 100; // center float dB = uiVolume.ToDecibelLevel(); // 0 dB
- HDRP dynamic resolution
- Caches
HDAdditionalCameraDataper camera viaConditionalWeakTableand sets both HDRP andCamera.allowDynamicResolutionflags
- Caches
- Editor‑aware destruction
- Uses
Object.DestroyImmediatein the Editor andObject.Destroyin Play Mode; theDestroy()helper removes children first to avoid leftovers
- Uses
- Formatting
- Replaces underscores, inserts spaces before capitals, and applies Title Case via the current culture
- Parsing and math
- Vector parsing uses
float.TryParseon current culture; invalid inputs yieldVector2.zero/Vector3.zero Remapis linear and does not clamp;Roundrounds each component;Divideis per‑component
- Vector parsing uses
- Interpolation
Lerptreats aVector2/Vector2Intas[min,max];Slerpeases byt^power(name refers to easing, not true spherical lerp)
- HDRP dependency (optional)
SetDynamicResolutionbenefits from HDRP’sHDAdditionalCameraData; without HDRP, onlyCamera.allowDynamicResolutionis toggled
- DestroyAllChildren
- Destroys entire GameObjects that contain
Tsomewhere below the given transform
- Destroys entire GameObjects that contain
- Culture‑sensitive parsing
ExtractVector*FromStringusesfloat.TryParsewith current locale; decimal separators (comma vs dot) must match
- Remap domain
Remapdivides by(sourceMax - sourceMin); ensure the source range is non‑zero and clamp externally if needed
- Interpolation naming
Slerphere is an eased linear interpolation, not geometric spherical interpolation
Runtime/UtilityExtensions.cs– Extension methods (camera, destroy helpers, components, strings, vectors, math, interpolation, audio)Runtime/UnityEssentials.UtilityExtensions.asmdef– Runtime assembly definitionpackage.json– Package manifest metadata
unity, utilities, extensions, helpers, camera, dynamic‑resolution, destroy, component, string, format, vector, parse, math, remap, interpolation, audio, decibel, hdrp
