uPIe Menu - Radial Menu
All Classes Namespaces Functions Properties Events
uPIe.uPIeMenu Class Reference

Contains the main uPIe menu (runtime) logic More...

Inheritance diagram for uPIe.uPIeMenu:

Public Member Functions

Vector2 GetDirection ()
 Gets the current direction from the center of the menu to the pointer (analogue stick direction or mouse position). More...
 
void PollInput ()
 Polls the input. More...
 
Vector2 GetIndicatorPosition (out Vector2 resultPosition)
 Gets the indicator position. More...
 
Vector2 GetIndicatorPosition (Vector2 dir, out Vector2 resultPosition)
 Gets the indicator position. More...
 
void ConfirmCurrentSelection ()
 Confirms the current selection (simulates a click respectively button down on the currently selected menu option). More...
 
Selectable SelectRelatedOption ()
 Selects the related option. The id stored in the field SelectedPieceId is used. More...
 
Selectable SelectRelatedOption (int id)
 Selects the related option by a given id. More...
 
void RemoveIndicator ()
 Removes the indicator. More...
 
Vector3 GetStartDirection (float additionalOffset=0)
 Gets the start direction. More...
 
Vector3 GetEndDirection (Vector3 startDir)
 Gets the end direction. More...
 
Vector3 GetEndDirection ()
 Gets the end direction. More...
 
Button AddButton (string name="", bool tryCopyFromLastMenuOption=true)
 Adds a new button (without adding it to the menu option list). In most cases you should use AddMenuOption as this sets up the button correctly and adds it to the menu options list More...
 
void InitMenuOption (GameObject instance, string name="")
 Initialize a newly created menu option gameobject instance More...
 
Button AddMenuOption ()
 Adds a new menu option (button) to the menu. More...
 
void AddMenuOptionAndRescaleX ()
 AddMenuOptionAndRealign takes more options than this, so from a script you should probably use that method. But unity only allows one parameter when calling methods from an event trigger (like OnClick) in the inspector, so if you want to do that, use this method. More...
 
void AddMenuOptionAndRescaleY ()
 AddMenuOptionAndRealign takes more options than this, so from a script you should probably use that method. But unity only allows one parameter when calling methods from an event trigger (like OnClick) in the inspector, so if you want to do that, use this method. More...
 
void AddMenuOptionAndRescaleZ ()
 AddMenuOptionAndRealign takes more options than this, so from a script you should probably use that method. But unity only allows one parameter when calling methods from an event trigger (like OnClick) in the inspector, so if you want to do that, use this method. More...
 
Button AddMenuOptionAndRealign (bool autoRescaleX=true, bool autoRescaleY=false, bool autoRescaleZ=false)
 Adds a new menu option (button) to the menu and automatically realigns the menu options according to what is set up in the alignment options. See AlignRadius, AlignRotation, AlignUpDirection, AlignForwardDirection More...
 
void RemoveMenuOptionAndRescaleX ()
 RemoveMenuOptionAndRealign takes more options than this, so from a script you should probably use that method. But unity only allows one parameter when calling methods from an event trigger (like OnClick) in the inspector, so if you want to do that, use this method. More...
 
void RemoveMenuOptionAndRescaleY ()
 RemoveMenuOptionAndRealign takes more options than this, so from a script you should probably use that method. But unity only allows one parameter when calling methods from an event trigger (like OnClick) in the inspector, so if you want to do that, use this method. More...
 
void RemoveMenuOptionAndRescaleZ ()
 RemoveMenuOptionAndRealign takes more options than this, so from a script you should probably use that method. But unity only allows one parameter when calling methods from an event trigger (like OnClick) in the inspector, so if you want to do that, use this method. More...
 
void RemoveMenuOptionAndRealign (bool autoRescaleX=true, bool autoRescaleY=false, bool autoRescaleZ=false)
 Removes the last menu option (button) from the menu and automatically realigns the menu options according to what is set up in the alignment options. See AlignRadius, AlignRotation, AlignUpDirection, AlignForwardDirection More...
 
void RemoveMenuOption ()
 Removes the most recently added menu option. More...
 
void RemoveMenuOption (int id)
 Removes the menu option by a given id. More...
 
void RemoveMenuOption (Selectable slct)
 Removes the menu option by a given selectable. More...
 
void ClearMenuOptions ()
 Clears all menu options. More...
 
void Deselect ()
 Deselects the currently selected menu option. More...
 
void OpenSubMenu (uPIeMenu subMenu)
 Opens a sub-uPIe-menu. More...
 
void ReturnToSuperMenu (uPIeMenu superMenu)
 Closes this sub-uPIe-menu and retuns to the uPIe-menu that is superordinated to this one. More...
 
void Realign ()
 Realigns all menu options. The options set up as alignment options are used. See AlignRadius, AlignRotation, AlignUpDirection, AlignForwardDirection More...
 
void Realign (float radius)
 Realigns all menu options by only using a different radius as set up in the alignment options. See AlignRadius, AlignRotation, AlignUpDirection, AlignForwardDirection More...
 
void Realign (float radius, bool doAlignRotation, Vector3 upDirection, Vector3 forwardDirection)
 Realigns all menu options by given options More...
 
void RescaleMenuOptions (float xScale, float yScale=1, float zScale=1, bool multiply=true)
 Rescales all menu options. More...
 

Properties

float ControllerDeadzone [get, set]
 Gets or sets the controller deadzone. This means, when is the analogue stick of the controller considered to be centered. More...
 
bool EnableSelecting [get, set]
 Gets or sets a value controlling whether selecting menu options is enabled or not. This is mostly used to enable or disable a parent menu when a submenu is opened or closed. More...
 
Selectable DefaultSelected [get, set]
 Gets or sets the option (button or other selectable) that is selected by default. This means this is what is selected, when the controllers analogue stick is centered More...
 
string HorizontalInputName [get, set]
 If unity default input is selected (no custom input) this is what the horizontal input is called in the input manager More...
 
string VerticalInputName [get, set]
 If unity default input is selected (no custom input) this is what the vertical input is called in the input manager More...
 
string ConfirmInputName [get, set]
 If unity default input is selected (no custom input) this is what the confirm input is called in the input manager More...
 
bool ConfirmButtonDown [get, set]
 If unity default input is used this returns, if the confirm button was pressed last frame Note: you can set this value too, but this is only recommended, if you want to create your own customized version of uPIe More...
 
Selectable CurrentlyActiveOption [get, set]
 Gets the menu option, that is currently active. Note: you can set the value too, but this should only be done, if you want to create your own, customized version of uPIe. More...
 
bool ConstrainIndicatorPosition [get, set]
 Gets or sets the value that determines whether to constrain the indicator position to the nearest menu option. This only makes a difference, when using menus that are not full circle. More...
 
float CircleSize [get, set]
 Gets or sets the size of the circle menu. More...
 
bool KeepSelectedOption [get, set]
 Gets or sets the the value, that determines whether to keep the most recently selected option with gamepad, when the stick is in "origin" position More...
 
Vector2 CurrentDirection [get, set]
 Gets or sets the current direction from center of the menu to pointer (mouse or analogue stick direction) More...
 
bool UseCustomInputSystem [get, set]
 Gets or sets a value indicating whether to use a custom input system or the unity default one. More...
 
Vector2 CustomInput [get, set]
 If we choose to use a custom input system, we need to set the direction (for analogue stick) or position (for mouse) here More...
 
int SelectedPieceId [get, set]
 Gets or sets the selected piece identifier. More...
 
float StartDegOffset [get, set]
 Gets or sets the offset in degrees where to start / where the first menu option should be More...
 
GameObject MenuOptionPrefab [get, set]
 Gets or sets the menu option prefab to use when creating new menu options More...
 
List< Selectable > MenuOptions [get, set]
 Gets or sets the menu options. More...
 
bool ApplyIndicatorRotation [get, set]
 Gets or sets a value indicating whether to apply indicator rotation or not. More...
 
Graphic IndicatorGraphic [get, set]
 Gets or sets the indicator graphic. More...
 
bool ControlWithGamepad [get, set]
 Gets or sets a value indicating whether to control with gamepad or not. More...
 
bool DeselectOptionIfOutsideBorders [get, set]
 Gets or sets a value indicating whether to deselect option if outside the menu borders. Note: only makes a difference when using menus that are not full circle More...
 
float AlignRadius [get, set]
 Gets or sets the align radius (align helper in the inspector) More...
 
bool AlignRotation [get, set]
 Gets or sets a value indicating whether the align helper (inspector) should also align rotation or not. More...
 
Vector3 AlignUpDirection [get, set]
 Gets or sets the up direction used for alignment. More...
 
Vector3 AlignForwardDirection [get, set]
 Gets or sets the forward direction used for alignment. More...
 

Detailed Description

Contains the main uPIe menu (runtime) logic

Member Function Documentation

◆ AddButton()

Button uPIe.uPIeMenu.AddButton ( string  name = "",
bool  tryCopyFromLastMenuOption = true 
)

Adds a new button (without adding it to the menu option list). In most cases you should use AddMenuOption as this sets up the button correctly and adds it to the menu options list

Parameters
nameA name for the button.
tryCopyFromLastMenuOptionIf set to true (default) this method will try to copy the most recently added menu option button
Returns

◆ AddMenuOption()

Button uPIe.uPIeMenu.AddMenuOption ( )

Adds a new menu option (button) to the menu.

Returns
The newly added menu option button

◆ AddMenuOptionAndRealign()

Button uPIe.uPIeMenu.AddMenuOptionAndRealign ( bool  autoRescaleX = true,
bool  autoRescaleY = false,
bool  autoRescaleZ = false 
)

Adds a new menu option (button) to the menu and automatically realigns the menu options according to what is set up in the alignment options. See AlignRadius, AlignRotation, AlignUpDirection, AlignForwardDirection

Parameters
autoRescaleXif set to true automatically rescales the x value.
autoRescaleYif set to true automatically rescales the y value.
autoRescaleZif set to true automatically rescales the z value.
Returns
The newly added menu option button

◆ AddMenuOptionAndRescaleX()

void uPIe.uPIeMenu.AddMenuOptionAndRescaleX ( )

AddMenuOptionAndRealign takes more options than this, so from a script you should probably use that method. But unity only allows one parameter when calling methods from an event trigger (like OnClick) in the inspector, so if you want to do that, use this method.

◆ AddMenuOptionAndRescaleY()

void uPIe.uPIeMenu.AddMenuOptionAndRescaleY ( )

AddMenuOptionAndRealign takes more options than this, so from a script you should probably use that method. But unity only allows one parameter when calling methods from an event trigger (like OnClick) in the inspector, so if you want to do that, use this method.

◆ AddMenuOptionAndRescaleZ()

void uPIe.uPIeMenu.AddMenuOptionAndRescaleZ ( )

AddMenuOptionAndRealign takes more options than this, so from a script you should probably use that method. But unity only allows one parameter when calling methods from an event trigger (like OnClick) in the inspector, so if you want to do that, use this method.

◆ ClearMenuOptions()

void uPIe.uPIeMenu.ClearMenuOptions ( )

Clears all menu options.

◆ ConfirmCurrentSelection()

void uPIe.uPIeMenu.ConfirmCurrentSelection ( )

Confirms the current selection (simulates a click respectively button down on the currently selected menu option).

◆ Deselect()

void uPIe.uPIeMenu.Deselect ( )

Deselects the currently selected menu option.

◆ GetDirection()

Vector2 uPIe.uPIeMenu.GetDirection ( )

Gets the current direction from the center of the menu to the pointer (analogue stick direction or mouse position).

Returns

◆ GetEndDirection() [1/2]

Vector3 uPIe.uPIeMenu.GetEndDirection ( Vector3  startDir)

Gets the end direction.

Parameters
startDirThe start dir.
Returns

◆ GetEndDirection() [2/2]

Vector3 uPIe.uPIeMenu.GetEndDirection ( )

Gets the end direction.

Returns

◆ GetIndicatorPosition() [1/2]

Vector2 uPIe.uPIeMenu.GetIndicatorPosition ( out Vector2  resultPosition)

Gets the indicator position.

Parameters
resultPositionThe resulting position.
Returns

◆ GetIndicatorPosition() [2/2]

Vector2 uPIe.uPIeMenu.GetIndicatorPosition ( Vector2  dir,
out Vector2  resultPosition 
)

Gets the indicator position.

Parameters
dirThe direction.
resultPositionThe resulting position.
Returns

◆ GetStartDirection()

Vector3 uPIe.uPIeMenu.GetStartDirection ( float  additionalOffset = 0)

Gets the start direction.

Parameters
additionalOffsetThe additional offset.
Returns

◆ InitMenuOption()

void uPIe.uPIeMenu.InitMenuOption ( GameObject  instance,
string  name = "" 
)

Initialize a newly created menu option gameobject instance

Parameters
instanceThe gameobject instance you want to be treated as a menu option
nameName the menu option gameobject (optional)

◆ OpenSubMenu()

void uPIe.uPIeMenu.OpenSubMenu ( uPIeMenu  subMenu)

Opens a sub-uPIe-menu.

Parameters
subMenuThe sub menu.

◆ PollInput()

void uPIe.uPIeMenu.PollInput ( )

Polls the input.

◆ Realign() [1/3]

void uPIe.uPIeMenu.Realign ( )

Realigns all menu options. The options set up as alignment options are used. See AlignRadius, AlignRotation, AlignUpDirection, AlignForwardDirection

◆ Realign() [2/3]

void uPIe.uPIeMenu.Realign ( float  radius)

Realigns all menu options by only using a different radius as set up in the alignment options. See AlignRadius, AlignRotation, AlignUpDirection, AlignForwardDirection

Parameters
radiusThe radius to align all options along.

◆ Realign() [3/3]

void uPIe.uPIeMenu.Realign ( float  radius,
bool  doAlignRotation,
Vector3  upDirection,
Vector3  forwardDirection 
)

Realigns all menu options by given options

Parameters
radiusThe radius.
doAlignRotationif set to true the menu options are also rotated.
upDirectionLocal up direction of the menu options.
forwardDirectionLocal forward direction of the menu options.

◆ RemoveIndicator()

void uPIe.uPIeMenu.RemoveIndicator ( )

Removes the indicator.

◆ RemoveMenuOption() [1/3]

void uPIe.uPIeMenu.RemoveMenuOption ( )

Removes the most recently added menu option.

◆ RemoveMenuOption() [2/3]

void uPIe.uPIeMenu.RemoveMenuOption ( int  id)

Removes the menu option by a given id.

Parameters
idThe identifier.

◆ RemoveMenuOption() [3/3]

void uPIe.uPIeMenu.RemoveMenuOption ( Selectable  slct)

Removes the menu option by a given selectable.

Parameters
slctThe selectable to remove.

◆ RemoveMenuOptionAndRealign()

void uPIe.uPIeMenu.RemoveMenuOptionAndRealign ( bool  autoRescaleX = true,
bool  autoRescaleY = false,
bool  autoRescaleZ = false 
)

Removes the last menu option (button) from the menu and automatically realigns the menu options according to what is set up in the alignment options. See AlignRadius, AlignRotation, AlignUpDirection, AlignForwardDirection

Parameters
autoRescaleXif set to true automatically rescales the x value.
autoRescaleYif set to true automatically rescales the y value.
autoRescaleZif set to true automatically rescales the z value.
Returns
The newly added menu option button

◆ RemoveMenuOptionAndRescaleX()

void uPIe.uPIeMenu.RemoveMenuOptionAndRescaleX ( )

RemoveMenuOptionAndRealign takes more options than this, so from a script you should probably use that method. But unity only allows one parameter when calling methods from an event trigger (like OnClick) in the inspector, so if you want to do that, use this method.

◆ RemoveMenuOptionAndRescaleY()

void uPIe.uPIeMenu.RemoveMenuOptionAndRescaleY ( )

RemoveMenuOptionAndRealign takes more options than this, so from a script you should probably use that method. But unity only allows one parameter when calling methods from an event trigger (like OnClick) in the inspector, so if you want to do that, use this method.

◆ RemoveMenuOptionAndRescaleZ()

void uPIe.uPIeMenu.RemoveMenuOptionAndRescaleZ ( )

RemoveMenuOptionAndRealign takes more options than this, so from a script you should probably use that method. But unity only allows one parameter when calling methods from an event trigger (like OnClick) in the inspector, so if you want to do that, use this method.

◆ RescaleMenuOptions()

void uPIe.uPIeMenu.RescaleMenuOptions ( float  xScale,
float  yScale = 1,
float  zScale = 1,
bool  multiply = true 
)

Rescales all menu options.

Parameters
xScaleThe x scale.
yScaleThe y scale.
zScaleThe z scale.
multiplyif set to true the scale is multiplied by its current scale. If set to false the scale value is directly set.

◆ ReturnToSuperMenu()

void uPIe.uPIeMenu.ReturnToSuperMenu ( uPIeMenu  superMenu)

Closes this sub-uPIe-menu and retuns to the uPIe-menu that is superordinated to this one.

Parameters
superMenuThe super menu.

◆ SelectRelatedOption() [1/2]

Selectable uPIe.uPIeMenu.SelectRelatedOption ( )

Selects the related option. The id stored in the field SelectedPieceId is used.

Returns

◆ SelectRelatedOption() [2/2]

Selectable uPIe.uPIeMenu.SelectRelatedOption ( int  id)

Selects the related option by a given id.

Parameters
idThe identifier.
Returns

Property Documentation

◆ AlignForwardDirection

Vector3 uPIe.uPIeMenu.AlignForwardDirection
getset

Gets or sets the forward direction used for alignment.

The align forward direction.

◆ AlignRadius

float uPIe.uPIeMenu.AlignRadius
getset

Gets or sets the align radius (align helper in the inspector)

The align radius.

◆ AlignRotation

bool uPIe.uPIeMenu.AlignRotation
getset

Gets or sets a value indicating whether the align helper (inspector) should also align rotation or not.

true if menu option rotation should be aligned; otherwise, false.

◆ AlignUpDirection

Vector3 uPIe.uPIeMenu.AlignUpDirection
getset

Gets or sets the up direction used for alignment.

The align up direction.

◆ ApplyIndicatorRotation

bool uPIe.uPIeMenu.ApplyIndicatorRotation
getset

Gets or sets a value indicating whether to apply indicator rotation or not.

true if indicator rotation should be applied; otherwise, false.

◆ CircleSize

float uPIe.uPIeMenu.CircleSize
getset

Gets or sets the size of the circle menu.

The size of the circle.

◆ ConfirmButtonDown

bool uPIe.uPIeMenu.ConfirmButtonDown
getset

If unity default input is used this returns, if the confirm button was pressed last frame Note: you can set this value too, but this is only recommended, if you want to create your own customized version of uPIe

◆ ConfirmInputName

string uPIe.uPIeMenu.ConfirmInputName
getset

If unity default input is selected (no custom input) this is what the confirm input is called in the input manager

◆ ConstrainIndicatorPosition

bool uPIe.uPIeMenu.ConstrainIndicatorPosition
getset

Gets or sets the value that determines whether to constrain the indicator position to the nearest menu option. This only makes a difference, when using menus that are not full circle.

◆ ControllerDeadzone

float uPIe.uPIeMenu.ControllerDeadzone
getset

Gets or sets the controller deadzone. This means, when is the analogue stick of the controller considered to be centered.

The controller deadzone.

◆ ControlWithGamepad

bool uPIe.uPIeMenu.ControlWithGamepad
getset

Gets or sets a value indicating whether to control with gamepad or not.

true if controlling with gamepad; otherwise, false.

◆ CurrentDirection

Vector2 uPIe.uPIeMenu.CurrentDirection
getset

Gets or sets the current direction from center of the menu to pointer (mouse or analogue stick direction)

The current direction.

◆ CurrentlyActiveOption

Selectable uPIe.uPIeMenu.CurrentlyActiveOption
getset

Gets the menu option, that is currently active. Note: you can set the value too, but this should only be done, if you want to create your own, customized version of uPIe.

◆ CustomInput

Vector2 uPIe.uPIeMenu.CustomInput
getset

If we choose to use a custom input system, we need to set the direction (for analogue stick) or position (for mouse) here

The custom input.

◆ DefaultSelected

Selectable uPIe.uPIeMenu.DefaultSelected
getset

Gets or sets the option (button or other selectable) that is selected by default. This means this is what is selected, when the controllers analogue stick is centered

◆ DeselectOptionIfOutsideBorders

bool uPIe.uPIeMenu.DeselectOptionIfOutsideBorders
getset

Gets or sets a value indicating whether to deselect option if outside the menu borders. Note: only makes a difference when using menus that are not full circle

true if the menu option should be deselected when outside the menus borders; otherwise, false.

◆ EnableSelecting

bool uPIe.uPIeMenu.EnableSelecting
getset

Gets or sets a value controlling whether selecting menu options is enabled or not. This is mostly used to enable or disable a parent menu when a submenu is opened or closed.

true if it should be able to select the options from this menu; otherwise, false.

◆ HorizontalInputName

string uPIe.uPIeMenu.HorizontalInputName
getset

If unity default input is selected (no custom input) this is what the horizontal input is called in the input manager

◆ IndicatorGraphic

Graphic uPIe.uPIeMenu.IndicatorGraphic
getset

Gets or sets the indicator graphic.

The indicator graphic.

◆ KeepSelectedOption

bool uPIe.uPIeMenu.KeepSelectedOption
getset

Gets or sets the the value, that determines whether to keep the most recently selected option with gamepad, when the stick is in "origin" position

◆ MenuOptionPrefab

GameObject uPIe.uPIeMenu.MenuOptionPrefab
getset

Gets or sets the menu option prefab to use when creating new menu options

The prefab asset to use

◆ MenuOptions

List<Selectable> uPIe.uPIeMenu.MenuOptions
getset

Gets or sets the menu options.

The menu options.

◆ SelectedPieceId

int uPIe.uPIeMenu.SelectedPieceId
getset

Gets or sets the selected piece identifier.

The selected piece identifier.

◆ StartDegOffset

float uPIe.uPIeMenu.StartDegOffset
getset

Gets or sets the offset in degrees where to start / where the first menu option should be

The start offset in degrees

◆ UseCustomInputSystem

bool uPIe.uPIeMenu.UseCustomInputSystem
getset

Gets or sets a value indicating whether to use a custom input system or the unity default one.

true if custom input system should be used; otherwise, false.

◆ VerticalInputName

string uPIe.uPIeMenu.VerticalInputName
getset

If unity default input is selected (no custom input) this is what the vertical input is called in the input manager