Class UnityRandomSource
Safe Random source based on UnityEngine.Random
Inherited Members
Namespace: RandomToolbox
Assembly: cs.temp.dll.dll
Syntax
[Serializable]
public class UnityRandomSource : RandomSourceBase
Constructors
UnityRandomSource()
Instantiate a new UnityRandomSource but does not initialize it
Declaration
public UnityRandomSource()
UnityRandomSource(SeedGenerators.Generator)
Instantiate a new UnityRandomSource with a new generated seed based on given seed generator
Declaration
public UnityRandomSource(SeedGenerators.Generator seedGenerator)
Parameters
Type | Name | Description |
---|---|---|
SeedGenerators.Generator | seedGenerator |
UnityRandomSource(Int32)
Instantiate a new UnityRandomSource and Initialize with given seed.
Declaration
public UnityRandomSource(int seed)
Parameters
Type | Name | Description |
---|---|---|
Int32 | seed | Seed to initialize the random generator |
UnityRandomSource(Random.State)
Instantiate a new UnityRandomSource with a given state
Declaration
public UnityRandomSource(Random.State state)
Parameters
Type | Name | Description |
---|---|---|
System.Random.State | state | the state to use for initialize |
Properties
insideUnitCircle
Returns a random point inside a circle with radius 1 (Read Only).
Declaration
public Vector2 insideUnitCircle { get; }
Property Value
Type | Description |
---|---|
Vector2 |
insideUnitSphere
Returns a random point inside a sphere with radius 1 (Read Only).
Declaration
public Vector3 insideUnitSphere { get; }
Property Value
Type | Description |
---|---|
Vector3 |
onUnitSphere
Returns a random point on the surface of a sphere with radius 1 (Read Only).
Declaration
public Vector3 onUnitSphere { get; }
Property Value
Type | Description |
---|---|
Vector3 |
rotation
Returns a random rotation (Read Only).
Declaration
public Quaternion rotation { get; }
Property Value
Type | Description |
---|---|
Quaternion |
rotationUniform
Returns a random rotation with uniform distribution (Read Only).
Declaration
public Quaternion rotationUniform { get; }
Property Value
Type | Description |
---|---|
Quaternion |
Sample
Create a new instance with the same random state to be used to preview values
Declaration
public UnityRandomSource Sample { get; }
Property Value
Type | Description |
---|---|
UnityRandomSource |
value
Returns a random number between 0.0 [inclusive] and 1.0 [inclusive] (Read Only).
Declaration
public float value { get; }
Property Value
Type | Description |
---|---|
Single |
Methods
ColorHSV()
Generates a random color from HSV and alpha ranges.
Declaration
public Color ColorHSV()
Returns
Type | Description |
---|---|
Color | A random color with HSV and alpha values in the input ranges. |
ColorHSV(Single, Single)
Generates a random color from HSV and alpha ranges.
Declaration
public Color ColorHSV(float hueMin, float hueMax)
Parameters
Type | Name | Description |
---|---|---|
Single | hueMin | Minimum hue [0..1]. |
Single | hueMax | Maximum hue [0..1]. |
Returns
Type | Description |
---|---|
Color | A random color with HSV and alpha values in the input ranges. |
ColorHSV(Single, Single, Single, Single)
Generates a random color from HSV and alpha ranges.
Declaration
public Color ColorHSV(float hueMin, float hueMax, float saturationMin, float saturationMax)
Parameters
Type | Name | Description |
---|---|---|
Single | hueMin | Minimum hue [0..1]. |
Single | hueMax | Maximum hue [0..1]. |
Single | saturationMin | Minimum saturation [0..1]. |
Single | saturationMax | Maximum saturation[0..1]. |
Returns
Type | Description |
---|---|
Color | A random color with HSV and alpha values in the input ranges. |
ColorHSV(Single, Single, Single, Single, Single, Single)
Generates a random color from HSV and alpha ranges.
Declaration
public Color ColorHSV(float hueMin, float hueMax, float saturationMin, float saturationMax, float valueMin, float valueMax)
Parameters
Type | Name | Description |
---|---|---|
Single | hueMin | Minimum hue [0..1]. |
Single | hueMax | Maximum hue [0..1]. |
Single | saturationMin | Minimum saturation [0..1]. |
Single | saturationMax | Maximum saturation[0..1]. |
Single | valueMin | Minimum value [0..1]. |
Single | valueMax | Maximum value [0..1]. |
Returns
Type | Description |
---|---|
Color | A random color with HSV and alpha values in the input ranges. |
ColorHSV(Single, Single, Single, Single, Single, Single, Single, Single)
Generates a random color from HSV and alpha ranges.
Declaration
public Color ColorHSV(float hueMin, float hueMax, float saturationMin, float saturationMax, float valueMin, float valueMax, float alphaMin, float alphaMax)
Parameters
Type | Name | Description |
---|---|---|
Single | hueMin | Minimum hue [0..1]. |
Single | hueMax | Maximum hue [0..1]. |
Single | saturationMin | Minimum saturation [0..1]. |
Single | saturationMax | Maximum saturation[0..1]. |
Single | valueMin | Minimum value [0..1]. |
Single | valueMax | Maximum value [0..1]. |
Single | alphaMin | Minimum alpha [0..1]. |
Single | alphaMax | Maximum alpha [0..1]. |
Returns
Type | Description |
---|---|
Color | A random color with HSV and alpha values in the input ranges. |
Range(Int32, Int32)
Return a random integer number between min [inclusive] and max exclusive.
Declaration
public int Range(int min, int max)
Parameters
Type | Name | Description |
---|---|---|
Int32 | min | min int value [inclusive] |
Int32 | max | max int value [exclusive] |
Returns
Type | Description |
---|---|
Int32 | random integer number |
Range(Single, Single)
Return a random float number between min [inclusive] and max inclusive.
Declaration
public float Range(float min, float max)
Parameters
Type | Name | Description |
---|---|---|
Single | min | min float value [inclusive] |
Single | max | max float value [inclusive] |
Returns
Type | Description |
---|---|
Single | random float number |
Restore(Random.State)
Restore the random source with the given state
Declaration
public void Restore(Random.State state)
Parameters
Type | Name | Description |
---|---|---|
System.Random.State | state |
Save()
Get the current state to save and restore it later
Declaration
public Random.State Save()
Returns
Type | Description |
---|---|
System.Random.State |
Start()
Initialize the Seed system with the current seed
Declaration
public override void Start()