A collection of modular, high-quality utilities for Unity development.
All files are licensed under the MIT License unless otherwise specified.
- Download or clone the repository
- Copy the entire Assets/PiDev folder into your Unity project's Assets directory.
- You now have full access to all utilities, components, and editor tools.
- Some utilities depend on DoTween by Demigiant. A version of it is included in Assets/DOTween. Make sure to manually update this when necessary, its provided only for the example project to work.
- Unity 2021.3 LTS or newer is recommended. (Older versions may work but are not officially tested.)
Pi-Dev Utilities is intended to include proper usage examples, but at the moment, a full sample package isn't available. Most utilities and components are straightforward to use, but I'm aware that a few β particularly the Adaptive UI tools β can feel complex or underdocumented.
In the future, I plan to add sample scenes to better demonstrate these tools in action, especially the Adaptive UI components.
Thanks for your patience and understanding!
βοΈ Core - mostly C# extension methods and other utils to ease development.
-
CollectionUtils.cs
Extension methods for safer and more convenient list, array, and collection operations.array.GetOrDefault(index, defaultValue); list.GetOrDefault(index, defaultValue); dictionary.GetOrDefault(key, fallbackValue); dictionary.GetOrNull(key); weightedList.GetByWeight(); // ICollection<Utils.Weighted<T>>
-
FindUtils.cs
Fast searching utilities for finding nearest objects, random objects, or tagged objects.transform.FindGrandChild("ChildName"); Utils.GetClosestPoint(origin, listOfPoints); Utils.GetClosestNumber(originValue, floatValues); Utils.GetClosestObject(origin, objects); // GameObjects or Transforms Utils.GetClosestObjectWithTag(origin, "Enemy"); Utils.GetAllComponents<UnityEngine.UI.Image>(); Utils.GetClosestObjectWithComponent<MyComponent>(origin); Utils.GetClosestComponent<MyComponent>(origin); Utils.GetClosestComponent(origin, allowedList); Utils.GetClosestObjectImplementingInterface<IMyInterface>(origin, 10f, excludeList);
-
ImporterUtils.cs
Scripts for reimporting assets and automatically applying settings like UI Sprite import mode.ImporterUtils.ImportAsUITexture("Assets/Path/To/Texture.png");
-
MathUtils.cs
A collection of mathematical utilities and vector extensions for common Unity tasks. Includes remapping, damping, snapping, rounding, component-wise vector operations, circular lerp, angle snapping, and coordinate conversion helpers.Most of these are extension methods to basic primitives and Unity types.
value.RemapRanges(oldMin, oldMax, newMin, newMax); pos = pos.Damp(target, smoothing, deltaTime); angle = Utils.clerp(startAngle, endAngle, t); vec = vec.RoundMemberwise(); // Also: FloorMemberwise(), CeilMemberwise(), AbsMemberwise() float snapped = value.Snap(0.5f); // or angle = SnapAngleDeg(angle, 45f); v3 = v2.xy0(); v2 = v3.xz(); max = vec3.Max3();
-
MiscUtils.cs
Miscellaneous helpers including layer checking, hashing & others.var mc = gameObject.GetOrAddComponent<MyComponent>(); gameObject.SetLayerRecursively(targetLayer); if (layer.IsInLayerMask(mask)) { ... } if (string.ContainsAny("check", "a", "b", "c")) { ... } myList.Each(item => Debug.Log(item));
-
RandomUtils.cs
Random selection helpers for arrays, lists, and weighted random picks.var item = Utils.Choose("A", "B", "C"); var fromList = myList.GetRandomElement(); var weighted = items.GetRandomElementByWeight(i => i.weight); float value = rangeVector2.RandomRange(); // rangeVector2 = new Vector2(min, max)
-
ReflectionUtils.cs
Access and manipulate private or public fields using reflection.ReflectionUtils.SetFieldValue(target, "fieldName", newValue); var value = ReflectionUtils.GetFieldValue(target, "fieldName"); ReflectionUtils.CopyPublicMembers(sourceComponent, targetComponent);
-
SplineUtils.cs
Generate and evaluate Catmull-Rom splines for smooth path interpolation.var points = PathSplineCatmullRom(controlPoints, loop, useLengths, resolution: 10)
-
TimeUtils.cs
Unix timestamp conversions for DateTime.long seconds = myDateTime.ToUnixTimeSeconds(); long millis = myDateTime.ToUnixTimeMS();
-
TransformUtils.cs
Useful extension methods for manipulating Transforms.Rect screenRect = Utils.RectTransformToScreenSpace(myRectTransform);
-
UnicodeUtils.cs
Utilities for working with Unicode text, especially "fancy" or stylized mathematical characters. Provides normalization to ASCII, identification of stylized letters, and surrogate pair handling. Useful for cleaning up user input, chat systems, or data normalization in multilingual contexts.string clean = someString.NormalizeLeetText(); bool isFancy = Utils.IsMathematicalLetter(codePoint); char ascii = Utils.ConvertToAsciiEquivalent(codePoint);
-
Interfaces.cs
Core interfaces for standardizing common behaviors across utilities.
π΅ Audio - Sound banks & immersive, responsive audio behaviors without heavy scripting
-
SoundBankSet.cs
Configurable sound bank utility for playing random spatial and 2D audio clips with randomized pitch and playback logic. Supports single-play and looping sounds with spatial blend, falloff settings, and optional clip shuffling. Ideal for sound effects, ambient audio systems, or dynamic audio behavior in Unity.[SerializeField] SoundBankSet soundBank; soundBank.Play(position); soundBank.Play2D(); soundBank.PlayLooping(position); soundBank.PlayLooping(followTransform);
-
SoundBankSetHolder.cs
Component wrapper for easy use of aSoundBankSet
with auto-play and filtering options. Supports optional low-pass filtering and radius visualization for editor debugging. Can delay playback on start and control sound lifecycle via Play/Stop.Attach to a GameObject, assign all clips and settings, and call Play() or enable PlayOnStart. Use 'useLowPassFilter' to add AudioLowPassFilter with custom frequency.
-
VelocityBasedAudioSource.cs
Dynamically plays friction and impact sounds based on velocity using customizable curves and SoundBankSets. Supports Rigidbody, Transform, or custom velocity providers for friction calculation.Attach to an object with Rigidbody or implement
IVelocityAudioSourceFrictionProvider
. AssignfrictionSound
andimpactSound
along with velocity-based curves.
π Management - Object pooler, Singleton, Reference wrapper
-
ObjectPooler.cs
Yet another lightweight object pool for reusing objects efficiently. This one is not Unity-specific and allows full customization.var pool = new ObjectPooler<MyType>(); pool.funcGenerate = () => new MyType(); pool.Stock(10); var item = pool.Buy(); pool.Recycle(item);
-
ReferenceWrapper.cs
Reference wrapper to value type,Ref<T>
allows structs to behave like references.var myRef = new Ref<int>(5); int value = myRef; // Implicitly converts to int myRef.Value = 10;
-
Singleton.cs
Yet another basic MonoBehaviour singleton implementation with duplicate protection.public class MyManager : Singleton<MyManager> { ... }
Access the singleton with
MyManager.instance
. -
ObjectReferences.cs
Keep strong references to assets to prevent stripping during builds. -
Honeypot.cs
Rudimentary security trick to catch people who mess with cheating engines and tools. Don't treat this as a true security solution.var honeypot = new Honeypot<int>(initialValue, () => Debug.Log("Tampering detected!")); honeypot.SetValue(newValue); var currentValue = honeypot.GetValue(); honeypot.CheckForTampering(); honeypot.Dispose();
π§© Helpers - Useful stuff for designers and programmers
-
CommentComponent.cs
A simple component for attaching notes or comments to GameObjects in the Unity Inspector.
Useful for leaving reminders or design-time annotations in scenes/prefabs. -
ActionButtons.cs
Quickly create dynamic buttons in the inspector bound to Actions.[Header("Content tools")] public ActionButtons actions = new ActionButtons("", new("Generate Board", () => GenerateChessboard()), new("Capture pieces", CapturePreviews), new("Export AssetBundle", () => Debug.Log("TODO!")) );
-
NaNFieldProperty.cs
Inspector attribute to easily set float fields to NaN (Not a Number).[NaNField] public float optionalValue;
Press the NaN button next to the field in the Inspector to set it to
float.NaN
.
π§ Logic - Common and uncommon behaviors, algorithms and components
-
AStarPathfinder.cs
A* pathfinding for 2D grid maps, customizable walkability.var grid = new int[width, height]; // Your grid representation var path = AStarPathfinder.FindPath(grid, start, goal, isWalkable); var simplified = AStarPathfinder.SimplifyPath(path);
-
CountdownTimer.cs
Simple countdown timer component with second-based events.timer.onSecondPassed.AddListener(sec => Debug.Log($"Seconds left: {sec}")); timer.onTimedOut.AddListener(() => Debug.Log("Timer finished")); timer.Start(seconds);
You also must call
timer.Update()
in your Update() method. -
DelayedDestroy.cs
Destroy a GameObject after a specified delay automatically.
Attach to a GameObject and set the delay in the inspector or via script. -
MeshParticleEmitter.cs
Emits particles from mesh and skinned mesh vertex positions using a given ParticleSystem. Supports dynamic velocity calculation based on mesh vertex distance and optional mesh exclusion. Useful for effects like mesh-based bursts, trails, or vertex-driven particle systems.MeshParticleEmitter.EmitFromMeshes(particleSystem, transform); MeshParticleEmitter.EmitFromMeshVertices(particleSystem, transform, velocityMultiplier, ignoreList);
-
PointDistributor.cs
Distributes a configurable number of points in 3D space based on selected shape: Line, Circle, or Path. Supports centering, custom overrides, and integration with external path providers like DoTweenPath. Also supports override sets for exact point configurations and Catmull-Rom interpolation for path shape.var points = pointDistributor.GetPoints(count);
-
ValueInterpolator.cs
Generic value interpolator for smoothly transitioning between values using linear or lerped modes. Accepts custom interpolation functions for full type flexibility (float, Vector types, Quaternion, etc.).var interp = ValueInterpolator.Float(0, 10); interp.targetValue = 20; interp.Update(Time.deltaTime); // you must call this when recalculation is needed Debug.Log(interp.currentValue);
Use the
Update()
method manually each frame, passingdeltaTime
to progress the interpolation. Supports different speeds for increasing vs. decreasing values via optionalnegativeSpeed
logic.
π Movement - Components for following targets, floating in place and other motion
-
FollowTarget.cs
Simple follow target script with Transform / Rigidbody movement modes. -
OrientWithTarget.cs
Continuously orient towards another transform. -
FollowMultiTargets.cs
Follows the average position and orientation of multiple target transforms. Supports optional axis snapping to align the resulting rotation with a reference transform. Useful for group tracking, midpoints, or collective indicators.Add transforms to
targets
and assign a reference toobjectRoot
for axis snapping.
AdjustaxisSnapStrength
to control how strongly to align with the reference up direction. -
FloatingObjectLocalSpaceMovement.cs
Adds oscillating movement and rotation in local space for floating effects. Can optionally sync with FollowTarget and OrientWithTarget components for dynamic references. Resets transform on disable to ensure consistent behavior when re-enabled.Attach to a GameObject with
FollowTarget
orOrientWithTarget
if needed.
Configure movement, frequency, and rotation axis in the inspector. -
FloatingObjectMovement.cs
Smoothly floats an object around its target using randomized paths.Attach to a GameObject and configure radius, interval, and damping.
Optionally assign a FollowTarget to float relative to another transform.
π₯οΈ User Interface - Adaptive containers, Canvas init & Mobile joystick
The UI module have some powerful yet very niche components for dynamic layout control.
-
RaycastTarget.cs
Invisible UI element to intercept or block raycasts without visuals. -
AdaptiveDPIScale.cs
Adjusts UI scale based on screen DPI for better readability. -
AdaptiveGridLayout.cs
Grid layout that adapts column and row count to screen aspect ratio. -
AdaptiveLayoutGroup.cs
Switch between vertical and horizontal layout groups dynamically. -
AdaptiveLayoutMode.cs
Fully switch active UI containers based on screen aspect or device. -
AspectRatioPreferredSizeScaler.cs
Dynamically scales a layout element based on preferred aspect ratio. -
CanvasInitialize.cs
Automatic Canvas configuration for touch-only devices or specific setups. This component was created to help me overcome the nonsense where canvases stay at (0,0) during edit time. With this you can make a world space canvas attached to editing camera, but still get overlay UI during runtime. -
ImagePreferredSizeScaler.cs
Auto-scale Image preferred size while preserving aspect ratio. -
MobileUIJoystick.cs
Mobile-friendly on-screen joystick with flexible snapping behavior.
π οΈ Editor - Action Toolbar and Spreadsheets for editing data
-
QuickActionToolbars.cs
Allows adding custom action buttons to the left and right of Unity's Play, Pause, and Step buttons. Useful for quickly accessing common tools, shortcuts, or scene actions directly from the main editor toolbar.Customize the toolbar by editing this script to define your own commands.
-
CollectionTable.cs
Editor window base class for managing serialized collections via a table.Inherit from
CollectionTable<T>
and callSetData(targetObject, "propertyPath")
to bind a serialized array.
UseGetWindow<YourDerivedCollectionTableThing>()
to create and display the window. -
ScriptableObjectTable.cs
Editor window base class for managing ScriptableObject assets in a table view.Inherit from
ScriptableObjectTable<T>
thenGetWindow<YourDerivedTable>()
to open the window. -
TableView.cs
A generic, reorderable and sortable Unity Editor table component with customizable columns. Supports custom drawing per column, sortable column modes, drag-and-drop row reordering, and selection tracking.Designed to be used by editor tools and inspectors for lists and serialized data displays.
var table = new TableView<MyDataType>(); table.AddColumn("Name", 100, (rect, item) => GUI.Label(rect, item.name)); /* inside OnGUI */ table.Render(myItemsArray);
Check
ScriptableObjectTable
andCollectionTable
for working example.
All content is under the MIT License, unless explicitly stated otherwise in specific files.
Some splines/math code credits: Paul Bourke.
DoTweenPath concept partially inspired by Bob Berkebile.
I'm Petar Petrov, known online as PeterSvP, an independent game developer and designer from Bulgaria. With a background in professional game development, including experience at Gameloft, I've transitioned to indie development, focusing on creating unique gaming experiences.
I'm the creator of ColorBlend FX: Desaturation, a 2.5D puzzle-platformer metroidvania.
Beyond game development, I engage with the world through various platforms:
- Instagram: instagram.com/petersvp
- Twitch: twitch.tv/petersvp
- Steam: steamcommunity.com/id/petersvp
- YouTube: youtube.com/petersvp
If you use Pi-Dev Utilities in your projects and like them, please consider supporting me by purchasing my games.
I may also be available for paid freelance projects. Check my profile on Upwork