RangedFloat/RangeType Range { get; set; }

book_4_sparkGenerated
code_blocksInput

Description

The Range property of the RangedFloat struct specifies the type of range that the float value represents. This can be either a fixed value or a range between a minimum and maximum value. The Range property is of type RangedFloat.RangeType, which defines the behavior of the float value.

Usage

Use the Range property to determine or set the type of range for a RangedFloat instance. This property is useful when you need to know whether the float value is fixed or if it should be randomized within a specified range.

To set the range type, assign a value from the RangedFloat.RangeType enumeration to the Range property. This will affect how the RangedFloat behaves when retrieving its value using methods like GetValue.

Example

// Example of using the RangedFloat struct and its Range property

// Create a RangedFloat with a fixed value
RangedFloat fixedFloat = new RangedFloat
{
    Range = RangedFloat.RangeType.Fixed,
    FixedValue = 10.0f
};

// Create a RangedFloat with a range value
RangedFloat rangedFloat = new RangedFloat
{
    Range = RangedFloat.RangeType.Range,
    Min = 5.0f,
    Max = 15.0f
};

// Check the range type
if (fixedFloat.Range == RangedFloat.RangeType.Fixed)
{
    // Do something with the fixed value
    float value = fixedFloat.FixedValue;
}

if (rangedFloat.Range == RangedFloat.RangeType.Range)
{
    // Get a random value within the range
    float randomValue = rangedFloat.GetValue();
}