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).

EnumTypeBuilder

Provides methods for constructing EnumType objects.
public class EnumTypeBuilder

Inherits from System.Object

To use this class, create an instance of it, and call the With-prefixed methods to set properties. When you're done, access the EnumType property to get the final, constructed EnumType.

#Properties

#EnumType

Gets the constructed enum type.
public EnumType EnumType { get; }

Type EnumType

#Methods

#FromEnum<TEnum>(string?)

Creates a new EnumType given a CLR enum type.
public static EnumType FromEnum<TEnum>(string? description = null)
    where TEnum : System.Enum

Type Parameters

  • TEnum
    The type of the CLR enum.

Parameters

  • descriptionstring
    An optional description to apply to the new Yarn enum type.

Returns EnumType: A Yarn type representing the enum.

#WithCase(string, float, string?)

Adds a new string case to the constructed enum type.
public EnumTypeBuilder WithCase(string caseName, float rawValue, string? description)

Parameters

  • caseNamestring
    The name of the case, as it appears in Yarn Spinner scripts.
  • rawValuefloat
    The raw value of the case.
  • descriptionstring
    The optional description for the case.
  • rawType(unknown)
    The type of the case.

Returns EnumTypeBuilder: The EnumTypeBuilder instance that received this method call.

Exceptions

  • System.ArgumentException
    Thrown if the raw type doesn't match the enum's type, if a case with the given name already exists, or if a case with the given value already exists.

#WithCase(string, string, string?)

Adds a new string case to the constructed enum type.
public EnumTypeBuilder WithCase(string caseName, string rawValue, string? description)

Parameters

  • caseNamestring
    The name of the case, as it appears in Yarn Spinner scripts.
  • rawValuestring
    The raw value of the case.
  • descriptionstring
    The optional description for the case.

Returns EnumTypeBuilder: The EnumTypeBuilder instance that received this method call.

Exceptions

  • System.ArgumentException
    Thrown if the raw type doesn't match the enum's type, if a case with the given name already exists, or if a case with the given value already exists.

#WithDescription(string)

Sets the Description property of the constructed enum type.
public EnumTypeBuilder WithDescription(string description)

Parameters

  • descriptionstring
    The new description.

Returns EnumTypeBuilder: The EnumTypeBuilder instance that received this method call.

#WithName(string)

Sets the Name property of the constructed enum type.
public EnumTypeBuilder WithName(string name)

Parameters

  • namestring
    The new name.

Returns EnumTypeBuilder: The EnumTypeBuilder instance that received this method call.

#WithRawType(IType)

Sets the RawType property of the constructed enum type.
public EnumTypeBuilder WithRawType(IType rawType)

Parameters

Returns EnumTypeBuilder: The EnumTypeBuilder instance that received this method call.

Exceptions

  • System.InvalidOperationException
    Thrown if the enum has any cases added to it.
  • System.ArgumentException
    Thrown if rawType is neither a string type nor a number type.

Generated from Yarn Spinner for Unity 3.3.