A Weatherlight custom made package with useful bite-sized development tools for anyone!
This package includes some minor utility tools that we often use to develop our games. You can see them and how they work in the following sections.
To use this package inside Unity simply open Window > Package Manager
, on the window that appears click the "+" icon and select "Add Package from git URL...", then paste the link you get from this repository (https://github.com/Cogno-Marco/WeatherUtils.git) and Unity will do the rest!
When Unity has downloaded and included this package you can directly use it (see next sections for tools found in the package and how to use them).
A collection of efficient bezier curves implementations
Simply call BezierCurves.
and then the function you want to use. Documentation can be found in the BezierCurves.cs
file and a usage example in CustomGizmosTester.cs
Available functions are divided in param-like Bezier curves (which return a single point on the curve) and list-like Bezier curves (which return a list of points on the curve)
Usage example
void Update(){
transform.position = BezierCurves.Quadratic(
new Vector3(0, 0, 0,),
new Vector3(0.5f, 2, 0.5f),
new Vector3(1, 0, 1),
Mathf.Sin(Time.time)
);
}
A collection of useful development Editor-only gizmos. You can see some of them here:
These gizmos only work inside OnDrawGizmos
and OnDrawGizmosSelected
Unity functions.
Simply setup a color and use them like this:
private void OnDrawGizmos(){
Gizmos.Color = Color.green;
CustomGizmos.DrawArrow(...);
CustomGizmos2D.DrawEllipse(...);
}
You can see documentation on each function in the CustomGizmos.cs
file and a usage example in CustomGizmosTester.cs
A simple Singleton class to avoid code duplication
Say you have public class YourClass : Monobehaviour
which you want to be a singleton. Simply write public class YourClass : Singleton<YourClass>
and the package will do the rest.
After that you get the Singleton Instance using YourClass.GetInstance()
.
An attribute used to create ReadOnly variables.
Simply mark a variable with [ReadOnly]
to make it read only (meaning you won't be able to edit it into the inspector, but you'll still be able to see it).
An attribute used to show a variable as a Graph over time.
Useful for debugging purposes.
Simply mark a variable with [Graph]
or [FGraph]
to see it in the inspector as a graph. During play every change to the variable will be seen in the graph in the inspector.
[Graph]
is updated in LateUpdate, while [FGraph]
is updated in FixedUpdate.
Contributions on this repository are accepted! To contribute:
- Create a new empty Unity project
- Navigate to the Unity project folder
- Enter the
Packages
folder - Create a new empty folder called
WeatherUtils
- Fork this repository into your account
- Clone your forked repository into the
WeatherUtils
folder - Edit, Create and Test what you want
- Create a pull-request into the original repository
The library use the MIT license, you can check LICENSE.md
for more details