Table of Contents

Class LayoutRoot

Namespace
MagicUI.Core
Assembly
MagicUI.dll

Entry point to create layouts

public class LayoutRoot
Inheritance
LayoutRoot
Inherited Members

Constructors

LayoutRoot(bool, string)

Creates a new layout root

public LayoutRoot(bool persist, string name = "New LayoutRoot")

Parameters

persist bool

Whether the layout will persist across scene transitions

name string

The name of the layout root and underlying canvas

Properties

Canvas

The unity Canvas underlying the layout.

public GameObject Canvas { get; }

Property Value

GameObject

Elements

A read-only collection of elements registered to this layout.

public IEnumerable<ArrangableElement> Elements { get; }

Property Value

IEnumerable<ArrangableElement>

Interactive

Whether the elements in this layout hierarchy should be interactive. When true (by default), the elements in the hierarchy will block interaction with other UI elements.

public bool Interactive { get; set; }

Property Value

bool

IsPersistent

Whether this is a persistent layout

public bool IsPersistent { get; }

Property Value

bool

Name

The name of the layout root

public string Name { get; }

Property Value

string

Opacity

The current opacity of elements in the layout hierarchy.

public float Opacity { get; set; }

Property Value

float

RenderDebugLayoutBounds

Whether to render the layout system bounds of elements in this layout for debugging purposes

public bool RenderDebugLayoutBounds { get; set; }

Property Value

bool

VisibilityCondition

A predicate that determines whether the layout should be visible. By default (i.e. when there is no condition), the layout is always visible.

public Func<bool>? VisibilityCondition { get; set; }

Property Value

Func<bool>

Methods

BeginFade(float, float)

Linearly fades the elements in this layout hierarchy to a new opacity value.

public void BeginFade(float targetOpacity, float fadeDuration)

Parameters

targetOpacity float

The target opacity.

fadeDuration float

The duration of time the fade should take to complete, in seconds.

Destroy()

Destroys the layout root and all of its child elements

public void Destroy()

ForceInteractivityRefresh()

Forces the interactivity controller to immediately re-evaluate interactivity conditions without needing to wait a frame

public void ForceInteractivityRefresh()

GetElement(string)

Gets an element in this layout by name

public ArrangableElement? GetElement(string name)

Parameters

name string

The name to search for

Returns

ArrangableElement

The first element in this layout with the given name if any exist, or else null

GetElement<T>(string)

Gets an element in this layout by name and type

public T? GetElement<T>(string name) where T : ArrangableElement

Parameters

name string

The name to search for

Returns

T

The first element in this layout with the given name and type if any exist, or else null

Type Parameters

T

The type of element to search for

GetElements(string)

Gets all elements in this layout by name

public IEnumerable<ArrangableElement> GetElements(string name)

Parameters

name string

The name to search for

Returns

IEnumerable<ArrangableElement>

All elements in this layout with the given name if any exist, or else an empty enumerable

GetElements<T>(string)

Gets all elements in this layout by name and type

public IEnumerable<T> GetElements<T>(string name) where T : ArrangableElement

Parameters

name string

The name to search for

Returns

IEnumerable<T>

All elements in this layout with the given name and type if any exist, or else an empty enumerable

Type Parameters

T

The type of element to search for

ListenForHotkey(KeyCode, Action, ModifierKeys, Func<bool>?)

Initializes a hotkey listener that performs an action when a given key combination is pressed

public void ListenForHotkey(KeyCode key, Action execute, ModifierKeys modifiers = ModifierKeys.None, Func<bool>? condition = null)

Parameters

key KeyCode

The keypress to listen for

execute Action

The action to perform when the key is pressed

modifiers ModifierKeys

Other required modifier keys that must be held to trigger the event

condition Func<bool>

The condition in which this hotkey should be enabled

ListenForPlayerAction(PlayerAction, Action, Func<bool>?)

Initializes a PlayerAction listener that performs an action when the PlayerAction IsPressed goes from False to True

public void ListenForPlayerAction(PlayerAction playerAction, Action execute, Func<bool>? condition = null)

Parameters

playerAction PlayerAction

The PlayerAction to bind to

execute Action

The action to perform when the PlayerAction is pressed

condition Func<bool>

The condition in which this action should be enabled