<aside>
Overview
Randomly is a comprehensive and easy-to-use random data generation library for Unity.
Important! The plugin uses the Xoshiro256 algorithm and always includes the maximum value!**
</aside>
<aside>
Randomly.
- SetSeed(int seed) – Set a fixed seed for deterministic random generation.
- SetRandomSeed() – Generates a new seed from a cryptographically secure RNG.
- Byte() / Byte(byte max) / Byte(byte min, byte max) – Generate random byte values.
- Int() / Int(int max) / Int(int min, int max) – Generate random integers.
- Float() / Float(float max) / Float(float min, float max) – Generate random floats.
- Double() / Double(double max) / Double(double min, double max) – Generate random double
- Bool() / Bool(float chance) – Generate random boolean values, optionally with a probability to be true.
using PahutyakV.Randomly;
// Random int value
int i = Randomly.Int(0, 2);
//Random bool value with a probability to be true (0-1)
bool b = Randomly.Bool(0.75f)
</aside>
<aside>
Randomly.Collection
Provides advanced random selection and shuffling utilities for collections. Supports equal probability selection, weighted selection, and selection with animation curves.
Choice Methods:
- Choice(list) – Random element from list.
- Choice(list, weights) – Random element using explicit weights.
- Choice(list, weightCurve) – Random element using an AnimationCurve to define weights.
- ChoicePop(list) – Random element and remove it from the list.
- ChoiceIndex(list) – Returns a random index.
Take Methods:
- Take(list, count) – Returns multiple random elements with equal probability.
- Take(list, weights, count) – Returns multiple random elements using weights.
- Take(list, weightCurve, count) – Returns multiple random elements using an AnimationCurve.
- TakePop(list, count) – Returns multiple random elements and removes them from the list.
- TakeIndexes(list, count) – Returns multiple random indexes from the list.
Shuffle Methods:
- Shuffle(list) – In-place shuffle of the entire list.
- ShuffleSection(list, start, end) – In-place shuffle of a subsection of the list.
- Shuffled(list) – Returns a shuffled copy without modifying the original list.
Usage Notes:
- Weighted and curve-based methods clamp negative weights to 0.
- Use classes WeightedList<T> and CurveWeightedList<T> for easy display in the inspector.
// Get random list element
List<int> myList = new List<int>() { 4, 7, 2, 8, 12 };
int v = Randomly.Collection.Choice(myList);
// Get random 2 list elements from WeightedList
List<int> values = myWeightedList.Take(2);
</aside>
<aside>
Randomly.DateTime
Provides random date, time, and day utilities.
Date Methods:
- Date(min, max) – Random date between min and max.
- DatePast(daysBack) – Random past date within last
daysBack days.
- DateFuture(daysForward) – Random future date within next
daysForward days.
- DateInYear(year) – Random date within a given year.
- DateInMonth(year, month) – Random date within a given month of a year.
Day Methods:
- Weekday() – Random day of the week (Monday–Sunday).
Time Methods:
- TimeOfDay() – Random time (hours, minutes, seconds).
// Random future date within next 60 days
DateTime future = Randomly.DateTime.DateFuture(60);
// Random time of day
TimeSpan time = Randomly.DateTime.TimeOfDay();
</aside>
<aside>
Randomly.Spatial
Provides random spatial values: vectors, quaternions, directions, and points inside/outside geometric shapes.
Vector Methods:
- Vector2 / Vector2Int – Random 2D vector in range or component-wise range.
- Vector3 / Vector3Int – Random 3D vector in range or component-wise range.
- Direction2D / Direction3D – Random normalized 2D or 3D direction.
- Between(Vector2/Vector3 a, b) – Linear interpolation between two vectors.
Quaternion Methods:
- Quaternion() / Quaternion(min,max) / Quaternion(minX,maxX,... ) – Random rotation using Euler angles.
- Rotation() – Random rotation as uniform quaternion.
- Between(Quaternion a,b) – Slerp between two rotations.
Spatial Methods:
- InsideCircle(radius) / OnCircle(radius) – Random 2D point inside/on a circle.
- InsideSphere(radius) / OnSphere(radius) – Random 3D point inside/on a sphere.
- InsideBox(size) / OnBox(size) – Random 3D point inside/on a box.
// Random Vector2
Vector2 v2 = Randomly.Spatial.Vector2(0f, 10f);
// Random Quaternion
Quaternion rotation = Randomly.Spatial.Rotation();
</aside>
<aside>
Randomly.Color
Provides random Color generation for Unity, supporting tones, ranges, and string/byte representations.
Color Generation Methods:
- Get(tone) – Random Color using a specific tone (
Any, Warm, Cool, Gray).
- Get(min, max) – Random Color with each channel in the given range.
String / RGB(A) Methods:
- Hex(includeAlpha) – Hexadecimal string of random color; alpha optional.
- RGB() – Random RGB as byte tuple.
- RGBA() – Random RGBA as byte tuple.
// Random warm color
Color warmColor = Randomly.Color.Get(RandomlyColor.ColorTone.Warm);
// Random hex color
string hexColor = Randomly.Color.Hex();
</aside>
<aside>
Randomly.Noise
Provides Perlin and Value noise generation for 1D, 2D, 3D spaces with optional fractal details.
Perlin Noise Methods:
- Perlin1D(x) – Generates 1D Perlin noise at position x.
- Perlin2D(x, y) – Generates 2D Perlin noise at coordinates (x, y).
- Perlin3D(x, y, z) – Generates 3D Perlin noise at coordinates (x, y, z).
- FractalPerlin2D(x, y, octaves, persistence, lacunarity) – Generates 2D fractal Perlin noise with multiple octaves.
Value Noise Methods:
- ValueNoise2D(x, y) – Generates 2D value noise at coordinates (x, y).
// Generate 2D Perlin noise
float noiseValue = Randomly.Noise.Perlin2D(3.5f, 7.2f);
// Generate fractal Perlin noise
float fractalNoise = Randomly.Noise.FractalPerlin2D(1.0f, 2.0f, octaves: 4, persistence: 0.5f, lacunarity: 2f);
</aside>
<aside>
</aside>
<aside>
</aside>
<aside>
</aside>