Switch branches/tags
Nothing to show
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
..
Failed to load latest commit information.
Editor
Editor.meta
README.md
README.md.meta
RangeFloat.cs
RangeFloat.cs.meta
RangeInt.cs
RangeInt.cs.meta

README.md

RangeInt/Float

RangeInt/RangeFloat are editable data types that take an int/float range. Used for things like "Spawn 2 to 4 enemies."

Example

RangeExample Editor Screenshot

public class RangeExample : MonoBehaviour
    {
        [SerializeField] RangeInt amountRange;
        [SerializeField] RangeFloat numberRange;

        private void Awake()
        {
            // Get a random number in amountRange
            int amount = amountRange.RandomInclusive;

            // Output [amount] numbers
            for (int i = 0; i < amount; i++)
            {
                // Transform [i..(amount-1)] to [0..1]
                var t = ((float)i / (amount - 1));

                // Mathf.Lerp(numberRange.From, numberRange.To, t)
                Debug.Log(numberRange.Lerp(t));
            }
        }
    }
}

Dependencies

None.