Ryle Radio 1.0.0
An open-source "radio" system for Unity, allowing tracks, tuning, broadcasters, and more!
Loading...
Searching...
No Matches
RyleRadio.MultiselectAttribute Class Reference

A custom attribute that allows ints to display as a multiselect dropdown for a given collection, like a custom LayerMask. Due to int limitations you can only have up to 32 options. More...

Inheritance diagram for RyleRadio.MultiselectAttribute:

Public Member Functions

 MultiselectAttribute (string _optionsName)
 Initialises the attribute.

Static Public Member Functions

static T[] To< T > (int _flags, T[] _options)
 Converts an int with the Multiselect attribute to a subset of a given list according to the int flags- converts the flag int to usable data.
static int[] ToInt (int _flags)
 Shorthand for MultiselectAttribute.To<int>(_flags, _options). Useful for converting a multiselect to indexes in a list.

Properties

string OptionsName [get, private set]
 Name of the variable this attribute uses for the options list.
static int[] ZeroTo31 [get]
 A filler array with numbers 0 - 31, used when converting from a flag int to a list subset.
static int[] OneTo32 [get]
 A filler array with numbers 1 - 32. Not yet used, but theoretically helpful for indexing from the end of a list (list[^i] instead of list[i])

Detailed Description

A custom attribute that allows ints to display as a multiselect dropdown for a given collection, like a custom LayerMask. Due to int limitations you can only have up to 32 options.

Has editor code in MultiselectDrawer

Definition at line 21 of file MultiselectAttribute.cs.

Constructor & Destructor Documentation

◆ MultiselectAttribute()

RyleRadio.MultiselectAttribute.MultiselectAttribute ( string _optionsName)

Initialises the attribute.

Definition at line 55 of file MultiselectAttribute.cs.

Member Function Documentation

◆ To< T >()

T[] RyleRadio.MultiselectAttribute.To< T > ( int _flags,
T[] _options )
static

Converts an int with the Multiselect attribute to a subset of a given list according to the int flags- converts the flag int to usable data.

Template Parameters
TThe eventType content of the list we're converting the flags to
Parameters
_flagsThe int with the Multiselect attribute- a flag int
_optionsThe list we're getting a subset of according to the flags
Returns
A subset of _options that matches the _flags int
string[] options = new string[4] { "awesome", "attribute", "thanks", "ryle-e" };
[Multiselect("options")]
public int flags1; // in the inspector, we set it to ["awesome", "thanks"]- the first and third options in the inspector. this int then becomes 0x0101
public void Convert()
{
int flags2 = (1 << 1) | (1 << 3); // equivalent to selecting the second and fourth options in the inspector
string[] converted1 = MultiselectAttribute.To<string>(flags1, options); // sets to ["awesome", "thanks"]
string[] converted2 = MultiselectAttribute.To<string>(flags2, options); // sets to ["attribute", "ryle-e"]
}
A custom attribute that allows ints to display as a multiselect dropdown for a given collection,...

Definition at line 82 of file MultiselectAttribute.cs.

◆ ToInt()

int[] RyleRadio.MultiselectAttribute.ToInt ( int _flags)
static

Shorthand for MultiselectAttribute.To<int>(_flags, _options). Useful for converting a multiselect to indexes in a list.

Parameters
_flagsThe int with the Multiselect attribute
Returns

Definition at line 118 of file MultiselectAttribute.cs.

Referenced by RyleRadio.Components.Base.RadioComponentDataAccessor.AssignToTracksGeneric(), and RyleRadio.Components.Base.RadioOutputTrackAccessor.DoTrackAction().

Property Documentation

◆ OneTo32

int [] RyleRadio.MultiselectAttribute.OneTo32
staticget

A filler array with numbers 1 - 32. Not yet used, but theoretically helpful for indexing from the end of a list (list[^i] instead of list[i])

Definition at line 43 of file MultiselectAttribute.cs.

◆ OptionsName

string RyleRadio.MultiselectAttribute.OptionsName
getprivate set

Name of the variable this attribute uses for the options list.

Definition at line 26 of file MultiselectAttribute.cs.

Referenced by MultiselectAttribute().

◆ ZeroTo31

int [] RyleRadio.MultiselectAttribute.ZeroTo31
staticget

A filler array with numbers 0 - 31, used when converting from a flag int to a list subset.

Definition at line 31 of file MultiselectAttribute.cs.

Referenced by ToInt().


The documentation for this class was generated from the following file: