Utilkit
is a collection of helpful utilities for Unity development. It includes a variety of helper functions and extensions for Vector3
, Vector2
, and more, as well as utilities for drawing gizmos and handling null checks.
- Vector3 Utilities: Extensions for basic vector operations like setting individual axes, adding, subtracting, and math functions (multiply, divide, clamp, etc.)
- Null Check Utilities: Simplified methods for checking and invoking actions on objects that are either null or not null.
- Gizmos Utilities: Tools to draw 2D and 3D shapes (e.g., circles, squares, cones, cylinders) using Gizmos in the Unity editor.
To use Utilkit
, add the following to your Packages/manifest.json
:
{
"dependencies": {
"com.bluepixel.utilkit": "https://github.com/bluepixeldev/utilkit.git"
}
}
- Download the repository as a ZIP file or clone it.
- Add the contents of the
BP.Utilkit
folder to your Unity project'sAssets
directory.
You can start using the utilities in your project by including the namespaces:
using BP.Utilkit;
Vector3 v = new Vector3(1, 2, 3);
v = v.SetX(5);
v = v.Add(new Vector2(1, 1));
v = v.Mul(2);
myObject.WithNotNull(obj => obj.DoSomething());
myObject.WithNull(() => Debug.Log("Object is null"));
void OnDrawGizmos() {
Gizmos2D.DrawWireCircle(transform.position, 2);
GizmoUtil.DrawCylinder(transform.position, 1, 5);
}
Detailed documentation is available in the GitHub Wiki.
Contributions are welcome! Feel free to submit issues and pull requests.
- Fork the repository.
- Create your feature branch (
git checkout -b feature/AmazingFeature
). - Commit your changes (
git commit -m 'Add new feature'
). - Push to the branch (
git push origin feature/AmazingFeature
). - Open a pull request.