https://github.com/iteria-llc/utility
https://github.com/iteria-llc/utility
unity unity-editor unity-package
Last synced: 5 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/iteria-llc/utility
- Owner: Iteria-LLC
- License: mit
- Created: 2023-12-12T10:54:26.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-12-04T01:29:19.000Z (over 1 year ago)
- Last Synced: 2025-02-13T22:16:48.177Z (over 1 year ago)
- Topics: unity, unity-editor, unity-package
- Language: C#
- Homepage: https://iteriagames.com
- Size: 25.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# utility
## How to install
Select "Add package from git URL..." in the Package Manager, and enter this URL:
```
https://github.com/Iteria-LLC/utility.git
```
#### Extension Methods
Collection indexing helpers, for arrays, lists, and dictionaries.
`void IncrementIndex(this ref int index, T[] array, bool wrap = true)`
`void DecrementIndex(this ref int index, T[] array, bool wrap = true)`
Returns index, wrapped to the bounds of the given collection.
```csharp
void NextWeapon()
{
//Scroll through weapons, wrapping back to 0 if necessary.
weaponIndex.IncrementIndex(weaponArray);
}
```
#### Maths Class
Namespaced under `Iteria` by default.
Optionally add scripting define symbol `ITERIA_DENAMESPACE` in player settings to put it in the root namespace for easier access.
#### Square Distance
Use static function `Square.Distance(a, b)` to perform distance comparisons without calculating square roots.
```csharp
if(Square.Distance(transform.position, point) < 5f)
Debug.Log("Within 5 meters!");
```