Ni-Extensions is a large set of extension methods for convenient work with different data types.
- Extension methods for all vectors, colors.
- Additional
GameObject
methods for working with components. - Methods for
Transform
,RectTransform
. - Extensions to interact with objects using monads.
- Unity 2021.2 or later
- Clone this repository or download the source files.
- Copy the
Ni-Extensions
folder into your Unity project'sAssets
directory.
- Open Package Manager from Window > Package Manager.
- Click the "+" button > Add package from git URL.
- Enter the following URL:
https://github.com/HoSHIZA/Ni-Extensions.git
- Open
manifest.json
. - Add the following line to the file:
"com.ni-games.extensions" : "https://github.com/HoSHIZA/Ni-Extensions.git"
bool @object = true;
@object
.If(predicate => predicate, value => Debug.Log(value)) // If i == true, call Debug.Log.
.Map(value => value.ToString()) // Mapping the `bool` value to the `string` type.
.ThrowIf(value => string.IsNullOrEmpty(value)) // If the value is null, an exception is thrown.
.With(value => Debug.LogWarning(value)); // Call Debug.LogWarning.
// Check code to details.
var vector = new Vector3(1, 2, 3);
// With
var vectorNew = vector.WithX(8); // Vector3(8, 2, 3)
var vectorNew = vector.WithYZ(33); // Vector3(1, 33, 33)
// Get
var vectorNew = vector.GetYZX(); // Vector3(2, 3, 1)
var vectorNew = vector.GetYX(); // Vector2(2, 1)
// Math operations
var vectorNew = vector.Sum(); // 6
var vectorNew = vector.Add(10); // Vector3(11, 12, 13)
var color = Color.red;
// With
var colorNew = color.WithG(0.75f); // Color(1f, 0.75f, 0f)
This project is licensed under the MIT License.