Unity Utils by kirillsmirnov1 - 1

Tools

Useful unity utilities

Unknown VersionUnknown LicenseUpdated 1 day agoCreated on September 8th, 2020
Go to source

Some little pieces of code I find useful enough to have them in several projects.

To install add next line to Packages/manifest.json
"trulden.unity-utils": "https://github.com/kirillsmirnov1/unity-utils.git",

MonoScale

Component to change scale of object with one slider.

VisualEffects

LazyFade component fades in and out all child components with Color. You can pass callback to SetVisibility() to be called when fade animation is finished.

UiFadePanel is helper component for LazyFade. Show() sets LazyFade child active and calls it’s SetVisibility(). Hide() does the opposite thing. Accepts finish callbacks similar to LazyFade.

Attributes

NamedArrayAttribute displays array indexes as given enum values.

UI

InvokableButton

Allows to «click» on button from code using Invoke().

Camera

FitCamera fits orthographic camera to chosen object in scene by width/height with chosen coefficient.

Saves

Call DateChecker.CheckSaveDate(DateTime) to check if any amount of days passed since date in question. If that is so, DateChecker.LoadOnNewDateCallback will be invoked. If not — DateChecker.LoadOnSameDateCallback.

With SaveIO you can write (and read) objects as JSON strings to (from) persistentDataPath.

Extensions

MonoBehaviourNullCheck

CheckNullFields(MonoBehaviour o) puts warnings in console, if object in questions has some public or private serialized fields being null.

GameObjectExtensions

InPrefabScene() checks if current object is in prefab scene. I use it in pair with CheckNullFields().

LINQ extensions

IEnumerable<T> Shuffle<T>() shuffles IEnumerable. It does so by calling OrderBy with some random values;

RandomExtensions

RandomValueInRangeSegment(float from, float to, int segmentCount, int segmentIndex)
Separates [from, to] to segmentCount ranges and generates random value in segmentIndex range.

DebugExtensions

DrawCross(Vector3 pos, float time, float length) draws debug cross

EnumExtensions

T Next<T>(this T src) where T : Enum returns next enum element. For last element returns first one.

Show all projects by kirillsmirnov1