MockRandom
public static class MockRandomSeedable random facade that all MockMagic generators route through.
Wraps a System.Random so results are reproducible across
runs, AOT/IL2CPP platforms and Edit/Play mode.
Call MockMagic.MockRandom.Seed(System.Int32) before generating data to get deterministic
output; MockMagic.MockRandom.ResetSeed restores the default wall-clock-seeded
behaviour.
Methods
Section titled “Methods”
Seed(int)
Section titled “Seed(int)”public static void Seed(int seed)Seed the random generator for reproducible output.
Also re-seeds UnityEngine.Random so Unity-internal randomness stays in sync.
Parameters
| Name | Type |
|---|---|
seed |
System.Int32 |
ResetSeed()
Section titled “ResetSeed()”public static void ResetSeed()Reset to the default time-seeded behaviour and clear the unique index counter.
Range(int, int)
Section titled “Range(int, int)”public static int Range(int minInclusive, int maxExclusive)Integer in [minInclusive, maxExclusive), matching UnityEngine.Random.Range(System.Int32%2cSystem.Int32).
Parameters
| Name | Type |
|---|---|
minInclusive |
System.Int32 |
maxExclusive |
System.Int32 |
Returns
System.Int32
Range(float, float)
Section titled “Range(float, float)”public static float Range(float min, float max)Float in [min, max], matching UnityEngine.Random.Range(System.Single%2cSystem.Single).
Parameters
| Name | Type |
|---|---|
min |
System.Single |
max |
System.Single |
Returns
System.Single
Value01()
Section titled “Value01()”public static float Value01()Float in [0, 1).
Returns
System.Single
NextDouble()
Section titled “NextDouble()”public static double NextDouble()Double in [0, 1).
Returns
System.Double
Bool()
Section titled “Bool()”public static bool Bool()Random boolean.
Returns
System.Boolean
Chance(float)
Section titled “Chance(float)”public static bool Chance(float probability)Random boolean biased by probability in [0, 1].
Parameters
| Name | Type |
|---|---|
probability |
System.Single |
Returns
System.Boolean
Gaussian(double, double)
Section titled “Gaussian(double, double)”public static double Gaussian(double mean, double standardDeviation)Random double drawn from a normal distribution.
Parameters
| Name | Type |
|---|---|
mean |
System.Double |
standardDeviation |
System.Double |
Returns
System.Double
GaussianFloat(float, float)
Section titled “GaussianFloat(float, float)”public static float GaussianFloat(float mean, float standardDeviation)Random float drawn from a normal distribution.
Parameters
| Name | Type |
|---|---|
mean |
System.Single |
standardDeviation |
System.Single |
Returns
System.Single
GaussianInt(double, double)
Section titled “GaussianInt(double, double)”public static int GaussianInt(double mean, double standardDeviation)Random int drawn from a normal distribution (rounded).
Parameters
| Name | Type |
|---|---|
mean |
System.Double |
standardDeviation |
System.Double |
Returns
System.Int32
Pick(params T[])
Section titled “Pick(params T[])”public static T Pick<T>(params T[] items)Pick a random element from an array.
Parameters
| Name | Type |
|---|---|
items |
{T}[] |
Returns
{T}
Pick(IReadOnlyList)
Section titled “Pick(IReadOnlyList)”public static T Pick<T>(IReadOnlyList<T> items)Pick a random element from a list.
Parameters
| Name | Type |
|---|---|
items |
System.Collections.Generic.IReadOnlyList{{T}} |
Returns
{T}
PickWeighted(params (float weight, T value)[])
Section titled “PickWeighted(params (float weight, T value)[])”public static T PickWeighted<T>(params (float weight, T value)[] items)Pick a random element biased by weights. Weights do not need to sum to 1.
Parameters
| Name | Type |
|---|---|
items |
System.ValueTuple{System.Single,{T}}[] |
Returns
{T}
Shuffle(IList)
Section titled “Shuffle(IList)”public static void Shuffle<T>(IList<T> items)Fisher-Yates shuffle in place.
Parameters
| Name | Type |
|---|---|
items |
System.Collections.Generic.IList{{T}} |
Subset(T[], int)
Section titled “Subset(T[], int)”public static T[] Subset<T>(T[] items, int count)Return a random subset of count unique items drawn from items.
Parameters
| Name | Type |
|---|---|
items |
{T}[] |
count |
System.Int32 |
Returns
{T}[]
Properties
Section titled “Properties”
IsSeeded
Section titled “IsSeeded”public static bool IsSeeded { get; }Whether MockMagic.MockRandom.Seed(System.Int32) has been called without a matching MockMagic.MockRandom.ResetSeed.
Returns
System.Boolean
UniqueIndex
Section titled “UniqueIndex”public static int UniqueIndex { get; }Ever-incrementing counter useful for producing collision-free values.
Reset by MockMagic.MockRandom.Seed(System.Int32) and MockMagic.MockRandom.ResetSeed.
Returns
System.Int32
PeekUniqueIndex
Section titled “PeekUniqueIndex”public static int PeekUniqueIndex { get; }Peek at the next unique index without consuming it.
Returns
System.Int32