Pardon our dust! Docs for Yarn Spinner for Unity 3.2 and Yarn Spinner for Godot C# are on docs.yarnspinner.dev (the old docs site). Docs for Yarn Spinner for Unity 3.3 (pre-release, out ASAP), Yarn Spinner for Godot GDScript and Yarn Spinner for Unreal Engine (work in progress) are on /docs/ (the new docs site).

EnumerableRandomExtension

Contains extension methods for System.Collections.Generic.IEnumerable`1.
public static class EnumerableRandomExtension

Inherits from System.Object

#Methods

#RandomElement<T>(IEnumerable<T>)

Returns a random element from enumerable.
public static T RandomElement<T>(this IEnumerable<T> enumerable)

Type Parameters

  • T
    The type of element in enumerable.

Parameters

  • enumerableIEnumerable<T>
    The collection to choose an item from.

Returns T: A random element in enumerable.

Exceptions

  • System.ArgumentException
    Thrown when enumerable contains no items.
This method uses System.Random to make a selection, which is cryptographically insecure. This means that this method should not be used for security-critical decisions.

Generated from Yarn Spinner for Unity 3.3.