CanvasController

public class CanvasController : MonoBehaviour, IStoryboardable;

Description

A canvas controller represents a single screen in your user interface. Canvas controllers can present and dismiss other canvas controllers, or screens, allowing you to easily build a user interface flow, presenting and dismissing screens as required. A canvas controller automatically manages the presentation hierarchy, as well as loading and unloading itself as it is presented or dismissed.

Canvas controllers should be created with Unity's Create menu - found by either right-clicking in the Project window or selecting Assets in the menu bar - and selecting Create/Canvas Flow/Canvas Controller.

Present and dismiss canvas controllers with the PresentCanvasController and DismissCanvasController methods. To present or dismiss an initial canvas controller use the PresentInitialCanvasController and DismissAllCanvasControllers methods.

A canvas controller can override its appearance methods to be notified of the appearance events CanvasWillAppear, CanvasDidAppear, CanvasWillDisappear, and CanvasDidDisappear.

Canvas controllers can be used with storyboards to visually define the presentation flow. When working with storyboards, data can be passed between canvas controllers by overriding the PrepareForStoryboardTransition method. Additionally, storyboard transitions can be triggered from a canvas controller using the PerformTransitionWithIdentifier method.

Canvas controllers can be presented in world space by either setting a storyboard's StoryboardPresentationSpace to WorldSpace, or by passing a CanvasControllerWorldSpaceContainer to PresentInitialCanvasController. Canvas controllers presented from a world space canvas controller will also be presented in world space and contained within the presenter's container.

Properties
backgroundImage The canvas controller's background image.
camera The canvas controller's camera.
canvas The canvas controller's main canvas.
ChildCanvasControllers Get the canvas controller's children.
content The canvas controller's content transform.
ContentActive Enable/disable the canvas contoller's content. This is equivalent to calling content.gameObject.activeSelf and content.gameObject.SetActive.
ContentPosition Get/set the position of the canvas controller's content. This is equivalent to calling content.localPosition.
ContentScale Get/set the scale of the canvas controller's content. This is equivalent to calling content.localScale.
Hidden Hide/show the canvas controller. This will enable/disable both the canvas controller's camera and content. Note that if the canvas controller is container within a CanvasControllerWorldSpaceContainer, only its content will be affected.
IsBeingDismissed Is the canvas controller currently being dismissed?
IsBeingPresented Is the canvas controller currently being presented?
IsEmbeddedInWorldSpaceContainer Is the canvas controller embedded in a world space container?
IsTransitioning Is the canvas controller currently transitioning?
presentationMode The canvas controller's presentation mode.
PresentedCanvasController Get the presented canvas controller.
PresentingCanvasController Get the presenting canvas controller - the canvas controller's presenter.
scene The canvas controller's scene.
Storyboard Get the canvas controller's storyboard.
transitioningAnimatorVendor The canvas controller's 'transitioning animator' vendor.
WorldSpaceContainer Get the canvas controller's world space container.
Methods
AddChildCanvasController Load the specified canvas controller and add it as a child.
AddChildCanvasController<T> Load the specified canvas controller and add it as a child.
AddChildCanvasController<T> Load the specified canvas controller and add it as a child.
Awake Awake is called when the canvas controller is loaded.
CanvasDidAppear Override this method in your canvas controller to be notified just after the canvas has transitioned on screen. This could be because it has just been presented or has just dismissed its PresentedCanvasController.
CanvasDidDisappear Override this method in your canvas controller to be notified just after the canvas has transitioned off screen. This could be because it has just been dismissed or has just presented a canvas controller.
CanvasWillAppear Override this method in your canvas controller to be notified just before the canvas is about to transition on screen. This could be because it is about to be presented or about to dismiss its PresentedCanvasController.
CanvasWillDisappear Override this method in your canvas controller to be notified just before the canvas is about to transition off screen. This could be because it is about to be dismissed or about to present a canvas controller.
DismissAllCanvasControllers Dismisses all canvas controllers in the current hierarchy.
DismissCanvasController Dismiss a canvas controller.
PerformTransitionWithIdentifier Perform the storyboard transition with this identifier.
PrepareForStoryboardTransition Override this method to be notified when the canvas controller is about to be involved in a storyboard transition.
PresentCanvasController Present a canvas controller, specifying a name.
PresentCanvasController<T> Present a canvas controller, specifying a type.
PresentCanvasController<T> Present a canvas controller, specifying a type and a name.
PresentInitialCanvasController Present an initial canvas controller, specifying a name.
PresentInitialCanvasController<T> Present an initial canvas controller, specifying a type.
PresentInitialCanvasController<T> Present an initial canvas controller, specifying a type and a name.
RemoveAndUnloadChildCanvasController Remove and unload a child canvas controller.
Start Start is called on the frame when the canvas controller is loaded, after Awake.

backgroundImage

public Image backgroundImage;

Description

The canvas controller's background image.


camera

public new Camera camera;

Description

The canvas controller's camera.


canvas

public Canvas canvas;

Description

The canvas controller's main canvas.


ChildCanvasControllers

public ReadOnlyCollection<CanvasController> ChildCanvasControllers;

Description

Get the canvas controller's children.

Use the AddChildCanvasController and RemoveAndUnloadChildCanvasController methods to add and remove child canvas controllers.


content

public RectTransform content;

Description

The canvas controller's content transform.

All content should be placed under the content transform.


ContentActive

public bool ContentActive;

Description

Enable/disable the canvas contoller's content. This is equivalent to calling content.gameObject.activeSelf and content.gameObject.SetActive.

If you intend to hide the canvas controller completely, use the Hidden property as this will disable the canvas' camera as well as the content.


ContentPosition

public Vector3 ContentPosition;

Description

Get/set the position of the canvas controller's content. This is equivalent to calling content.localPosition.


ContentScale

public Vector3 ContentScale;

Description

Get/set the scale of the canvas controller's content. This is equivalent to calling content.localScale.


Hidden

public bool Hidden;

Description

Hide/show the canvas controller. This will enable/disable both the canvas controller's camera and content. Note that if the canvas controller is container within a CanvasControllerWorldSpaceContainer, only its content will be affected.


IsBeingDismissed

public bool IsBeingDismissed;

Description

Is the canvas controller currently being dismissed?

Will return true if the canvas controller is currently involved in a transition in which it is being dismissed.


IsBeingPresented

public bool IsBeingPresented;

Description

Is the canvas controller currently being presented?

Will return true if the canvas controller is currently involved in a transition in which it is being presented.


IsEmbeddedInWorldSpaceContainer

public bool IsEmbeddedInWorldSpaceContainer;

Description

Is the canvas controller embedded in a world space container?

When a canvas controller is presented in world space, it is contained within a CanvasControllerWorldSpaceContainer.


IsTransitioning

public bool IsTransitioning;

Description

Is the canvas controller currently transitioning?

This returns true on both canvas controllers involved in a transition whilst that transition is executing.


presentationMode

public CanvasControllerPresentationMode presentationMode = CanvasControllerPresentationMode.HidePresenter;

Description

The canvas controller's presentation mode.

See also:

CanvasControllerPresentationMode


PresentedCanvasController

public CanvasController PresentedCanvasController;

Description

Get the presented canvas controller.

If this canvas controller has not presented a canvas controller then the presented canvas controller will be null.


PresentingCanvasController

public CanvasController PresentingCanvasController;

Description

Get the presenting canvas controller - the canvas controller's presenter.

If no canvas controller presented this canvas controller then the presenting canvas controller will be null. This is true for initial canvas controllers - canvas controllers presented from a storyboard entry transition or using PresentInitialCanvasController.


scene

protected Scene scene;

Description

The canvas controller's scene.


Storyboard

public Storyboard Storyboard;

Description

Get the canvas controller's storyboard.

When a canvas controller is presented from a storyboard, this property will be set to the storyboard whom presented it. Otherwise, it will be null.


transitioningAnimatorVendor

public ICanvasControllerTransitioningAnimatorVendor transitioningAnimatorVendor;

Description

The canvas controller's 'transitioning animator' vendor.

When a canvas controller is about to be presented or dismissed, it will ask its transitioningAnimatorVendor for an animator to animate the transition. Specify a vendor to supply transition animators to a transitioning canvas controller.


WorldSpaceContainer

public CanvasControllerWorldSpaceContainer WorldSpaceContainer;

Description

Get the canvas controller's world space container.

When a canvas controller is presented in world space, it is contained within a CanvasControllerWorldSpaceContainer. In this scenario, this property will be set to the container. Otherwise, it will be null.


AddChildCanvasController

public void AddChildCanvasController(string canvasControllerName, RectTransform childContainer = null, System.Action<CanvasController> configuration = null, System.Action<CanvasController> completion = null, bool loadAsynchronously = true);

Parameters

Name Description
canvasControllerName The name of the canvas controller to add.
childContainer The parent's rect transform under which the child should be added.
configuration A configuration action, called after the canvas controller has been loaded but before it has been added as a child.
completion A completion action, called after the canvas controller has been added as a child.
loadAsynchronously Should the child canvas controller be loaded asynchronously? By default, all canvas controllers are loaded asynchronously.

Description

Load the specified canvas controller and add it as a child.

This method will load the specified canvas controller and add it as a child of the receiving canvas controller. This causes the child canvas controller to be added to the parent's hierarchy under the specified transform. The child canvas controller's camera will be disabled and it will now be rendered by its parent's camera.


AddChildCanvasController<T>

public void AddChildCanvasController<T>(RectTransform childContainer = null, System.Action<T> configuration = null, System.Action<T> completion = null, bool loadAsynchronously = true) where T : CanvasController;

Parameters

Name Description
T The type of the canvas controller to add.
childContainer The parent's rect transform under which the child should be added.
configuration A configuration action, called after the canvas controller has been loaded but before it has been added as a child.
completion A completion action, called after the canvas controller has been added as a child.
loadAsynchronously Should the child canvas controller be loaded asynchronously? By default, all canvas controllers are loaded asynchronously.

Description

Load the specified canvas controller and add it as a child.

This method will load the specified canvas controller and add it as a child of the receiving canvas controller. This causes the child canvas controller to be added to the parent's hierarchy under the specified transform. The child canvas controller's camera will be disabled and it will now be rendered by its parent's camera.


AddChildCanvasController<T>

public void AddChildCanvasController<T>(string canvasControllerName, RectTransform childContainer = null, System.Action<T> configuration = null, System.Action<T> completion = null, bool loadAsynchronously = true) where T : CanvasController;

Parameters

Name Description
T The type of the canvas controller to add.
canvasControllerName The name of the canvas controller to add.
childContainer The parent's rect transform under which the child should be added.
configuration A configuration action, called after the canvas controller has been loaded but before it has been added as a child.
completion A completion action, called after the canvas controller has been added as a child.
loadAsynchronously Should the child canvas controller be loaded asynchronously? By default, all canvas controllers are loaded asynchronously.

Description

Load the specified canvas controller and add it as a child.

This method will load the specified canvas controller and add it as a child of the receiving canvas controller. This causes the child canvas controller to be added to the parent's hierarchy under the specified transform. The child canvas controller's camera will be disabled and it will now be rendered by its parent's camera.


Awake

protected virtual void Awake();

Description

Awake is called when the canvas controller is loaded.

If you override Awake, always call base.Awake() in your derived class's implementation.


CanvasDidAppear

protected virtual void CanvasDidAppear();

Description

Override this method in your canvas controller to be notified just after the canvas has transitioned on screen. This could be because it has just been presented or has just dismissed its PresentedCanvasController.

See also:

IsBeingPresented

IsBeingDismissed


CanvasDidDisappear

protected virtual void CanvasDidDisappear();

Description

Override this method in your canvas controller to be notified just after the canvas has transitioned off screen. This could be because it has just been dismissed or has just presented a canvas controller.

See also:

IsBeingPresented

IsBeingDismissed


CanvasWillAppear

protected virtual void CanvasWillAppear();

Description

Override this method in your canvas controller to be notified just before the canvas is about to transition on screen. This could be because it is about to be presented or about to dismiss its PresentedCanvasController.

See also:

IsBeingPresented

IsBeingDismissed


CanvasWillDisappear

protected virtual void CanvasWillDisappear();

Description

Override this method in your canvas controller to be notified just before the canvas is about to transition off screen. This could be because it is about to be dismissed or about to present a canvas controller.

See also:

IsBeingPresented

IsBeingDismissed


DismissAllCanvasControllers

public void DismissAllCanvasControllers(bool animated = true, System.Action completion = null);

Parameters

Name Description
animated Is the transition animated?
completion A completion action, called after the canvas controller has been dismissed.

Description

Dismisses all canvas controllers in the current hierarchy.

This method dismisses all canvas controllers in the current presentation stack. Only the top-most canvas controller will be animated in the transition. All canvas controllers in the stack will be unloaded.


DismissCanvasController

public void DismissCanvasController(bool animated = true, System.Action completion = null);

Parameters

Name Description
animated Is the transition animated?
completion A completion action, called after the canvas controller has been dismissed.

Description

Dismiss a canvas controller.

This method dismisses the canvas controller's top-most PresentedCanvasController - i.e. its PresentedCanvasController's PresentedCanvasController's... etc. If any intermediary canvas controllers exist between this canvas controller and the top-most presented one, they will be unloaded. Only the top-most canvas controller and this canvas controller will be animated during the transition.

If this canvas controller has no PresentedCanvasController, it will be dismissed by its PresentingCanvasController.

If this canvas controller is an initial canvas controller, it will be dismissed completely.


PerformTransitionWithIdentifier

public void PerformTransitionWithIdentifier(string identifier);

Parameters

Name Description
identifier Identifier.

Description

Perform the storyboard transition with this identifier.

If a canvas controller has been loaded from a storyboard, its storyboard transitions can be triggered with this method. The identifier specified must be set on the transition in the storyboard editor. If a canvas controller has not been loaded from a storyboard, its Storyboard property will be null.


PrepareForStoryboardTransition

public virtual void PrepareForStoryboardTransition(StoryboardTransition transition);

Parameters

Name Description
transition The storyboard transition, which provides information about the transition such as the canvas controllers involved.

Description

Override this method to be notified when the canvas controller is about to be involved in a storyboard transition.

When a transition occurs in a storyboard, the transition's source canvas controller will have its PrepareForStoryboardTransition method called. This gives an opportunity to pass data between canvas controllers.

This method will only be called on a canvas controller whom has been loaded from a storyboard.


PresentCanvasController

public void PresentCanvasController(string canvasControllerName, bool animated = true, System.Action<CanvasController> configuration = null, System.Action<CanvasController> completion = null, Vector3? canvasWorldPositionOverride = null, bool loadAsynchronously = true);

Parameters

Name Description
canvasControllerName The name of the canvas controller to present.
animated Is the transition animated?
configuration A configuration action, called after the canvas controller has been loaded but before it has been presented.
completion A completion action, called after the canvas controller has been presented.
canvasWorldPositionOverride A position in world space at which to place the loaded canvas controller. If no override is specified, the canvas controller will be positioned next to the presenting canvas controller.
loadAsynchronously Should the canvas controller be loaded asynchronously? By default, all canvas controllers are loaded asynchronously.

Description

Present a canvas controller, specifying a name.

The specified canvas controller's scene will be loaded and subsequently presented by this canvas controller.


PresentCanvasController<T>

public void PresentCanvasController<T>(bool animated = true, System.Action<T> configuration = null, System.Action<T> completion = null, Vector3? canvasWorldPositionOverride = null, bool loadAsynchronously = true) where T : CanvasController;

Parameters

Name Description
T The type of the canvas controller to present.
animated Is the transition animated?
configuration A configuration action, called after the canvas controller has been loaded but before it has been presented.
completion A completion action, called after the canvas controller has been presented.
canvasWorldPositionOverride A position in world space at which to place the loaded canvas controller. If no override is specified, the canvas controller will be positioned next to the presenting canvas controller.
loadAsynchronously Should the canvas controller be loaded asynchronously? By default, all canvas controllers are loaded asynchronously.

Description

Present a canvas controller, specifying a type.

The specified canvas controller's scene will be loaded and subsequently presented by this canvas controller.


PresentCanvasController<T>

public void PresentCanvasController<T>(string canvasControllerName, bool animated = true, System.Action<T> configuration = null, System.Action<T> completion = null, Vector3? canvasWorldPositionOverride = null, bool loadAsynchronously = true) where T : CanvasController;

Parameters

Name Description
T The type of the canvas controller to present.
canvasControllerName The name of the canvas controller to present.
animated Is the transition animated?
configuration A configuration action, called after the canvas controller has been loaded but before it has been presented.
completion A completion action, called after the canvas controller has been presented.
canvasWorldPositionOverride A position in world space at which to place the loaded canvas controller. If no override is specified, the canvas controller will be positioned next to the presenting canvas controller.
loadAsynchronously Should the canvas controller be loaded asynchronously? By default, all canvas controllers are loaded asynchronously.

Description

Present a canvas controller, specifying a type and a name.

The specified canvas controller's scene will be loaded and subsequently presented by this canvas controller.


PresentInitialCanvasController

public static void PresentInitialCanvasController( string canvasControllerName, System.Action<CanvasController> configuration = null, System.Action<CanvasController> completion = null, bool animated = true, Vector3? canvasWorldPositionOverride = null, bool loadAsynchronously = true, CanvasControllerWorldSpaceContainer worldSpaceContainer = null);

Parameters

Name Description
canvasControllerName The name of the canvas controller to present.
configuration A configuration action, called after the canvas controller has been loaded but before it has been presented.
completion A completion action, called after the canvas controller has been presented.
animated Is the transition animated?
canvasWorldPositionOverride A position in world space at which to place the loaded canvas controller. If no override is specified, the canvas controller will be positioned next to the presenting canvas controller.
loadAsynchronously Should the canvas controller be loaded asynchronously? By default, all canvas controllers are loaded asynchronously.
worldSpaceContainer Specify a world space container to present this canvas controller in world space.

Description

Present an initial canvas controller, specifying a name.

This method is used to present an initial canvas controller - the first canvas controller in the hierarchy. From there, the PresentCanvasController and DismissCanvasController methods can be used.


PresentInitialCanvasController<T>

public static void PresentInitialCanvasController<T>( System.Action<T> configuration = null, System.Action<T> completion = null, bool animated = true, Vector3? canvasWorldPositionOverride = null, bool loadAsynchronously = true, CanvasControllerWorldSpaceContainer worldSpaceContainer = null) where T : CanvasController;

Parameters

Name Description
T The type of the canvas controller to present.
configuration A configuration action, called after the canvas controller has been loaded but before it has been presented.
completion A completion action, called after the canvas controller has been presented.
animated Is the transition animated?
canvasWorldPositionOverride A position in world space at which to place the loaded canvas controller. If no override is specified, the canvas controller will be positioned next to the presenting canvas controller.
loadAsynchronously Should the canvas controller be loaded asynchronously? By default, all canvas controllers are loaded asynchronously.
worldSpaceContainer Specify a world space container to present this canvas controller in world space.

Description

Present an initial canvas controller, specifying a type.

This method is used to present an initial canvas controller - the first canvas controller in the hierarchy. From there, the PresentCanvasController and DismissCanvasController methods can be used.


PresentInitialCanvasController<T>

public static void PresentInitialCanvasController<T>( string canvasControllerName, System.Action<T> configuration = null, System.Action<T> completion = null, bool animated = true, Vector3? canvasWorldPositionOverride = null, bool loadAsynchronously = true, CanvasControllerWorldSpaceContainer worldSpaceContainer = null) where T : CanvasController;

Parameters

Name Description
T The type of the canvas controller to present.
canvasControllerName The name of the canvas controller to present.
configuration A configuration action, called after the canvas controller has been loaded but before it has been presented.
completion A completion action, called after the canvas controller has been presented.
animated Is the transition animated?
canvasWorldPositionOverride A position in world space at which to place the loaded canvas controller. If no override is specified, the canvas controller will be positioned next to the presenting canvas controller.
loadAsynchronously Should the canvas controller be loaded asynchronously? By default, all canvas controllers are loaded asynchronously.
worldSpaceContainer Specify a world space container to present this canvas controller in world space.

Description

Present an initial canvas controller, specifying a type and a name.

This method is used to present an initial canvas controller - the first canvas controller in the hierarchy. From there, the PresentCanvasController and DismissCanvasController methods can be used.


RemoveAndUnloadChildCanvasController

public void RemoveAndUnloadChildCanvasController(CanvasController canvasController);

Parameters

Name Description
canvasController The child canvas controller to remove and unload.

Description

Remove and unload a child canvas controller.


Start

protected virtual void Start();

Description

Start is called on the frame when the canvas controller is loaded, after Awake.