Class ViewController<TViewController, TView, TWindow, TViewResource, TTransition, TTransitionContext, TTransitionAnimatorProvider, TTransitionProgressProvider, TTransitionAnimationDriver, TTransitionAnimationDefaultProgressProvider, TTransitionData, TGraph>
A view controller manages a single view of content in your user-interface. It manages the life-cycle of its view and is responsible for instantiating and destroying its view as required, such as upon presentation or dismissal.
Do not create instances of this class directly. Instead, use one of the concrete base classes, CanvasController or ElementsController, depending on the workflow you are using.
Inheritance
System.Object
UnityEngine.Object
UnityEngine.ScriptableObject
ViewController<TViewController, TView, TWindow, TViewResource, TTransition, TTransitionContext, TTransitionAnimatorProvider, TTransitionProgressProvider, TTransitionAnimationDriver, TTransitionAnimationDefaultProgressProvider, TTransitionData, TGraph>
Inherited Members
UnityEngine.ScriptableObject.SetDirty()
UnityEngine.ScriptableObject.CreateInstance(System.String)
UnityEngine.ScriptableObject.CreateInstance(System.Type)
UnityEngine.ScriptableObject.CreateInstance<T>()
UnityEngine.Object.GetInstanceID()
UnityEngine.Object.GetHashCode()
UnityEngine.Object.Equals(System.Object)
UnityEngine.Object.Instantiate(UnityEngine.Object, UnityEngine.Vector3, UnityEngine.Quaternion)
UnityEngine.Object.Instantiate(UnityEngine.Object, UnityEngine.Vector3, UnityEngine.Quaternion, UnityEngine.Transform)
UnityEngine.Object.Instantiate(UnityEngine.Object)
UnityEngine.Object.Instantiate(UnityEngine.Object, UnityEngine.Transform)
UnityEngine.Object.Instantiate(UnityEngine.Object, UnityEngine.Transform, System.Boolean)
UnityEngine.Object.Instantiate<T>(T)
UnityEngine.Object.Instantiate<T>(T, UnityEngine.Vector3, UnityEngine.Quaternion)
UnityEngine.Object.Instantiate<T>(T, UnityEngine.Vector3, UnityEngine.Quaternion, UnityEngine.Transform)
UnityEngine.Object.Instantiate<T>(T, UnityEngine.Transform)
UnityEngine.Object.Instantiate<T>(T, UnityEngine.Transform, System.Boolean)
UnityEngine.Object.Destroy(UnityEngine.Object, System.Single)
UnityEngine.Object.Destroy(UnityEngine.Object)
UnityEngine.Object.DestroyImmediate(UnityEngine.Object, System.Boolean)
UnityEngine.Object.DestroyImmediate(UnityEngine.Object)
UnityEngine.Object.FindObjectsOfType(System.Type)
UnityEngine.Object.DontDestroyOnLoad(UnityEngine.Object)
UnityEngine.Object.DestroyObject(UnityEngine.Object, System.Single)
UnityEngine.Object.DestroyObject(UnityEngine.Object)
UnityEngine.Object.FindSceneObjectsOfType(System.Type)
UnityEngine.Object.FindObjectsOfTypeIncludingAssets(System.Type)
UnityEngine.Object.FindObjectsOfType<T>()
UnityEngine.Object.FindObjectOfType<T>()
UnityEngine.Object.FindObjectsOfTypeAll(System.Type)
UnityEngine.Object.FindObjectOfType(System.Type)
UnityEngine.Object.ToString()
UnityEngine.Object.name
UnityEngine.Object.hideFlags
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetType()
System.Object.MemberwiseClone()
Assembly: UI Graph API Documentation Project.dll
Syntax
public abstract class ViewController<TViewController, TView, TWindow, TViewResource, TTransition, TTransitionContext, TTransitionAnimatorProvider, TTransitionProgressProvider, TTransitionAnimationDriver, TTransitionAnimationDefaultProgressProvider, TTransitionData, TGraph> : ScriptableObject, IViewControllerAppearance, IAppearable, ITransitionContextViewController, IGraphableTransitionViewObjectContainer, IGraphableTransitionInvoker, IGraphableEmbedContainer, IGraphable where TViewController : ViewController<TViewController, TView, TWindow, TViewResource, TTransition, TTransitionContext, TTransitionAnimatorProvider, TTransitionProgressProvider, TTransitionAnimationDriver, TTransitionAnimationDefaultProgressProvider, TTransitionData, TGraph> where TView : IView<TView, TWindow> where TWindow : TView where TViewResource : ViewResource<TView, TWindow> where TTransition : ViewControllerTransition<TViewController, TTransition, TTransitionContext, TTransitionAnimatorProvider, TTransitionProgressProvider, TTransitionAnimationDriver, TTransitionAnimationDefaultProgressProvider>, new()
where TTransitionContext : ViewControllerTransitionContext<TViewController> where TTransitionAnimatorProvider : class, IViewControllerTransitionAnimatorProvider<TTransitionContext> where TTransitionProgressProvider : class, IViewControllerTransitionProgressProvider<TTransitionContext> where TTransitionAnimationDriver : ViewControllerTransitionAnimationDriver<TTransitionContext, TTransitionAnimationDefaultProgressProvider>, new()
where TTransitionAnimationDefaultProgressProvider : class, IViewControllerTransitionProgressProvider<TTransitionContext>, new()
where TTransitionData : ViewControllerInvokeTransitionData<TViewController>, new()
where TGraph : class
Type Parameters
Name |
Description |
TViewController |
|
TView |
|
TWindow |
|
TViewResource |
|
TTransition |
|
TTransitionContext |
|
TTransitionAnimatorProvider |
|
TTransitionProgressProvider |
|
TTransitionAnimationDriver |
|
TTransitionAnimationDefaultProgressProvider |
|
TTransitionData |
|
TGraph |
|
Fields
graph
The view controller's graph, if instantiated from a graph. Otherwise, null.
Declaration
Field Value
interactiveTransitionProgressProvider
The view controller's interactive transition progress provider is responsible for providing progress updates during an interactive transition.
Declaration
public TTransitionProgressProvider interactiveTransitionProgressProvider
Field Value
Type |
Description |
TTransitionProgressProvider |
|
The OnDidPerformChildTransition event is called just after the view controller has performed a transition between two of its child view controllers.
Declaration
public ViewController<TViewController, TView, TWindow, TViewResource, TTransition, TTransitionContext, TTransitionAnimatorProvider, TTransitionProgressProvider, TTransitionAnimationDriver, TTransitionAnimationDefaultProgressProvider, TTransitionData, TGraph>.DidPerformChildTransitionEvent OnDidPerformChildTransition
Field Value
The OnWillPerformChildTransition event is called just before the view controller performs a transition between two of its child view controllers.
Declaration
public ViewController<TViewController, TView, TWindow, TViewResource, TTransition, TTransitionContext, TTransitionAnimatorProvider, TTransitionProgressProvider, TTransitionAnimationDriver, TTransitionAnimationDefaultProgressProvider, TTransitionData, TGraph>.WillPerformChildTransitionEvent OnWillPerformChildTransition
Field Value
opaque
Is the view controller opaque? When a view controller is presented, its presenter is hidden if it is opaque. When opaque is set to false, i.e. the view controller is transparent, the presenter of this view controller will not be hidden upon presentation.
Declaration
Field Value
Type |
Description |
System.Boolean |
|
title
The view controller's title. This will be displayed by standard containers, such as the navigation and tab bar view controllers.
Declaration
Field Value
Type |
Description |
System.String |
|
transitionAnimatorProvider
The view controller's transition animator provider is responsible for providing transition animators when this view controller performs a transition. You may use your own provider or alter the animators returned by the default providers to customize a view controller's transition animations.
Declaration
public TTransitionAnimatorProvider transitionAnimatorProvider
Field Value
Type |
Description |
TTransitionAnimatorProvider |
|
Properties
AsAppearable
Declaration
public IAppearable AsAppearable { get; }
Property Value
DismissTransitionIdentifier
Declaration
protected abstract ViewControllerTransitionIdentifier DismissTransitionIdentifier { get; }
Property Value
Is the view controller performing a transition between child view controllers?
Declaration
protected bool IsPerformingTransitionBetweenChildren { get; }
Property Value
Type |
Description |
System.Boolean |
|
Parent
The view controller's parent view controller. If this view controller has been added as a child of another view controller, returns its parent view controller. Otherwise, returns null.
Declaration
protected TViewController Parent { get; }
Property Value
Type |
Description |
TViewController |
|
PresentedViewController
The view controller's presented view controller. If the view controller has not presented a view controller, returns null.
Declaration
public TViewController PresentedViewController { get; protected set; }
Property Value
Type |
Description |
TViewController |
|
PresentedViewControllerStack
The view controller's presentation stack starting from the receiving view controller. Beginning at the receiving view controller, this method visits each view controller's PresentedViewController to form the presentation stack. UI Graph uses this method when dismissing to destroy any intermediary view controllers if necessary.
Declaration
public Stack<TViewController> PresentedViewControllerStack { get; }
Property Value
Type |
Description |
System.Collections.Generic.Stack<TViewController> |
|
PresentingViewController
The view controller's presenting view controller – its presenter. If no view controller presented this view controller, returns null. This is true for root view controllers.
Declaration
public TViewController PresentingViewController { get; set; }
Property Value
Type |
Description |
TViewController |
|
PresentTransitionIdentifier
Declaration
protected abstract ViewControllerTransitionIdentifier PresentTransitionIdentifier { get; }
Property Value
RootAncestor
The view controller's root ancestor or top-most parent.
Declaration
protected TViewController RootAncestor { get; }
Property Value
Type |
Description |
TViewController |
|
View
The view controller's view. If the view is not loaded, it will be instantiated. Use ViewIsLoaded to determine whether the view has been loaded.
Declaration
public TView View { get; set; }
Property Value
ViewIsLoaded
Is the view controller's view loaded?
Declaration
public bool ViewIsLoaded { get; }
Property Value
Type |
Description |
System.Boolean |
|
Methods
AddChild(TViewController)
Add viewController
as a child of this view controller. This method configures the parent/child relationship between the two view controllers. You are still responsible for embedding its view, as required.
Declaration
public void AddChild(TViewController viewController)
Parameters
Type |
Name |
Description |
TViewController |
viewController |
|
Awake()
Declaration
protected virtual void Awake()
BindActivationListenerToViewObjects(IGraphableTransitionViewObjectListener)
Declaration
protected abstract void BindActivationListenerToViewObjects(IGraphableTransitionViewObjectListener viewObjectActivationListener)
Parameters
CanDismissViewController(out Error)
Can this view controller dismiss its presented view controller?
Declaration
public bool CanDismissViewController(out Error error)
Parameters
Type |
Name |
Description |
Error |
error |
|
Returns
Type |
Description |
System.Boolean |
True if this view controller can dismiss a view controller. False otherwise.
|
CanPresentViewController(TViewController, out Error)
Can viewController
currently be presented by this view controller?
Declaration
public bool CanPresentViewController(TViewController viewController, out Error error)
Parameters
Type |
Name |
Description |
TViewController |
viewController |
|
Error |
error |
|
Returns
Type |
Description |
System.Boolean |
True if viewController can be presented. False otherwise.
|
Destroy()
Destroy this view controller instance. If the view controller's view has been loaded, it will be unloaded.
Declaration
public virtual void Destroy()
Override this method to be notified just after the view controller has performed a transition between two of its child view controllers.
Declaration
protected virtual void DidPerformChildTransition(TTransition transition, bool completed)
Parameters
Type |
Name |
Description |
TTransition |
transition |
|
System.Boolean |
completed |
|
Dismiss(Boolean, Action)
Dismiss this view controller's top-most PresentedViewController. If any intermediary canvas controllers exist between this canvas controller and the top-most presented one, they will be hidden and subsequently destroyed. Only the top-most canvas controller and this canvas controller will be animated during the transition.
If this canvas controller has no PresentedViewController, it will be dismissed by its PresentingViewController.
If this method is called on a child view controller, it will automatically be forwarded to its RootAncestor.
Declaration
public void Dismiss(bool animated = true, Action completion = null)
Parameters
Type |
Name |
Description |
System.Boolean |
animated |
|
System.Action |
completion |
|
DismissInteractively(Action)
Declaration
public void DismissInteractively(Action completion = null)
Parameters
Type |
Name |
Description |
System.Action |
completion |
|
FindGraphableEmbedViewObjectsInView()
Declaration
protected abstract IGraphableEmbedViewObject[] FindGraphableEmbedViewObjectsInView()
Returns
FirstAncestorOfType<T>()
Query the view controller's parent hierarchy for the first ancestor of type T
.
Declaration
protected T FirstAncestorOfType<T>()
where T : TViewController
Returns
Type |
Description |
T |
The closest ancestor view controller of type T
|
Type Parameters
GraphableTransitionIdentifiers()
Container view controllers override this method to return the transition identifiers that they wish to expose to graphing.
Declaration
protected virtual List<GraphableTransitionIdentifier> GraphableTransitionIdentifiers()
Returns
ImplementsTransition(ViewControllerTransitionIdentifier)
Container view controllers override this method to return true for their own transition types.
Declaration
protected virtual bool ImplementsTransition(ViewControllerTransitionIdentifier transitionIdentifier)
Parameters
Returns
Type |
Description |
System.Boolean |
True if this view controller implements the transition identified by transitionIdentifier
|
InvokeTransition(ViewControllerTransitionIdentifier, TViewController, Boolean, Action)
Declaration
public void InvokeTransition(ViewControllerTransitionIdentifier transitionIdentifier, TViewController viewController = null, bool animated = true, Action completion = null)
Parameters
InvokeTransition(ViewControllerTransitionIdentifier, TTransitionData, Action)
Invoke a view controller transition in this view controller or any of its parents. Beginning a the receiving view controller, this method will iterate up the parent hierarchy until it reaches a view controller whom can perform the transition. If multiple view controllers that can perform the transition exist within the parent hierarchy, the view controller closest in depth to the receiver will be used. If no view controller is found to perform the transition, an error will be logged to the console.
Declaration
public void InvokeTransition(ViewControllerTransitionIdentifier transitionIdentifier, TTransitionData transitionData, Action completion = null)
Parameters
See Also
InvokeTransitionInteractively(ViewControllerTransitionIdentifier, TViewController, Action)
Declaration
public void InvokeTransitionInteractively(ViewControllerTransitionIdentifier transitionIdentifier, TViewController viewController = null, Action completion = null)
Parameters
LoadView()
Loads the view controller's view from its resource. You do not need to call this method directly. It is called internally when the view controller's view is required.
Override this method if you wish to create your view entirely from code instead of using a view resource.
Declaration
protected virtual void LoadView()
OnDestroy()
Declaration
protected virtual void OnDestroy()
OnDisable()
Declaration
protected virtual void OnDisable()
OnEnable()
Declaration
protected virtual void OnEnable()
Container view controllers may call this method to execute a transition between children. Both the to and from view controllers must be members of this view controller's 'children' list. This method will automatically make this view controller the 'owner' of the transition. This method will store the transition internally throughout its life-cycle. Upon completion it will be destroyed. When a view controller is destroyed, any executing transitions will be cancelled.
Declaration
protected void PerformChildTransition(ViewControllerTransitionIdentifier identifier, TViewController toViewController, TViewController fromViewController, bool animated, bool interactive, Stack<TViewController> intermediaryViewControllers = null, UnityAction<TTransition> OnTransitionBegan = null, UnityAction<TTransition, bool> OnTransitionWillFinish = null, UnityAction<TTransition, bool> OnTransitionDidFinish = null)
Parameters
Type |
Name |
Description |
ViewControllerTransitionIdentifier |
identifier |
|
TViewController |
toViewController |
|
TViewController |
fromViewController |
|
System.Boolean |
animated |
|
System.Boolean |
interactive |
|
System.Collections.Generic.Stack<TViewController> |
intermediaryViewControllers |
|
UnityEngine.Events.UnityAction<TTransition> |
OnTransitionBegan |
|
UnityEngine.Events.UnityAction<TTransition, System.Boolean> |
OnTransitionWillFinish |
|
UnityEngine.Events.UnityAction<TTransition, System.Boolean> |
OnTransitionDidFinish |
|
Declaration
public void PerformGraphTransitionWithIdentifier(string userIdentifier, object invoker)
Parameters
Type |
Name |
Description |
System.String |
userIdentifier |
|
System.Object |
invoker |
|
Declaration
protected virtual void PerformInvokedTransition(ViewControllerTransitionIdentifier transitionIdentifier, TTransitionData transitionData, Action completion)
Parameters
PrepareForGraphEmbed(TViewController)
Derived classes can override this method to be notified when a view controller is about to embed a view controller, as configured in a graph. This offers an opportunity to pass data to embedded view controllers.
Declaration
protected virtual void PrepareForGraphEmbed(TViewController viewControllerToBeEmbedded)
Parameters
Type |
Name |
Description |
TViewController |
viewControllerToBeEmbedded |
|
PrepareForGraphTransition(GraphTransition<TViewController>)
Derived classes can override this method to be notified when a view controller is about to be involved in a graph transition. This offers an opportunity to pass data between view controllers.
Declaration
protected virtual void PrepareForGraphTransition(GraphTransition<TViewController> transition)
Parameters
Present(TViewController, Boolean, Action)
Present viewController
. The specified view controller will be added to the view controller's window, causing its view to be loaded, and subsequently presented.
If this method is called on a child view controller, it will automatically be forwarded to its RootAncestor.
Declaration
public void Present(TViewController viewController, bool animated = true, Action completion = null)
Parameters
Type |
Name |
Description |
TViewController |
viewController |
|
System.Boolean |
animated |
|
System.Action |
completion |
|
PresentInteractively(TViewController, Action)
Declaration
public void PresentInteractively(TViewController viewController, Action completion = null)
Parameters
Type |
Name |
Description |
TViewController |
viewController |
|
System.Action |
completion |
|
See Also
ReceiverForTransition(ViewControllerTransitionIdentifier)
Declaration
public TViewController ReceiverForTransition(ViewControllerTransitionIdentifier transitionIdentifier)
Parameters
Returns
Type |
Description |
TViewController |
The first view controller in the view controller's parent hierarchy whom can perform the transitionIdentifier , or null if none was found.
|
RemoveFromParent()
Remove the view controller from its parent view controller. This method configures the parent/child relationship between this view controller and its parent. You are still responsible for removing its view, as required.
Declaration
public void RemoveFromParent()
Derived classes can override this method to control whether their graphable transitions (returned by GraphableTransitionIdentifiers()) are performed or ignored.
Declaration
protected virtual bool ShouldPerformGraphTransition(GraphTransition<TViewController> graphTransition, out Error error)
Parameters
Returns
Type |
Description |
System.Boolean |
True if the transition should be performed. False otherwise.
|
TryGetAnyChildTransition(out TTransition)
Retrieve any child transition in progress. If a transition between child view controllers is in progress, returns true and populates transition
with the transition object. Otherwise, returns false and transition
will be null. This can be useful if your container only supports one transition at a time, such as the Tab Bar and Stack controllers.
Declaration
protected bool TryGetAnyChildTransition(out TTransition transition)
Parameters
Type |
Name |
Description |
TTransition |
transition |
|
Returns
Type |
Description |
System.Boolean |
True if a child transition is in progress. False otherwise.
|
TryGetChildTransition(ViewControllerTransitionIdentifier, out TTransition)
Retrieve a specific child transition in progress. If a transition between child view controllers of the specified identifier
is in progress, returns true and populates transition
with the transition object. Otherwise, returns false and transition
will be null. This can be useful if your container supports multiple concurrent child transitions.
Declaration
protected bool TryGetChildTransition(ViewControllerTransitionIdentifier identifier, out TTransition transition)
Parameters
Returns
Type |
Description |
System.Boolean |
True if a child transition with the specified identifier is in progress. False otherwise.
|
ViewDidAppear()
ViewDidAppear is called after the view has appeared on-screen and after the transition has completed. Override this method to be notified just after the view has appeared on-screen.
Declaration
protected virtual void ViewDidAppear()
ViewDidDisappear()
ViewDidDisappear is called after the view has disappeared off-screen and after the transition has completed. Override this method to be notified just after the view has disappeared off-screen.
Declaration
protected virtual void ViewDidDisappear()
ViewDidLoad()
ViewDidLoad is called immediately after the view controller's view has been instantiated and is therefore called only once during your view controller's life-cycle. Override this method to perform additional one-time view setup.
Declaration
protected virtual void ViewDidLoad()
ViewWillAppear()
ViewWillAppear is called prior to the view appearing on-screen and before the transition has begun. Override this method to be notified just before the view is about to appear on-screen.
Declaration
protected virtual void ViewWillAppear()
ViewWillDisappear()
ViewWillDisappear is called prior to the view disappearing off-screen and before the transition has begun. Override this method to be notified just before the view is about to disappear off-screen.
Declaration
protected virtual void ViewWillDisappear()
Override this method to be notified just before the view controller performs a transition between two of its child view controllers.
Declaration
protected virtual void WillPerformChildTransition(TTransition transition)
Parameters
Type |
Name |
Description |
TTransition |
transition |
|
Explicit Interface Implementations
IAppearable.BeginAppearanceTransition(Boolean)
Declaration
void IAppearable.BeginAppearanceTransition(bool isAppearing)
Parameters
Type |
Name |
Description |
System.Boolean |
isAppearing |
|
IAppearable.EndAppearanceTransition()
Declaration
void IAppearable.EndAppearanceTransition()
IGraphable.GraphableTransitionIdentifiers()
Declaration
List<GraphableTransitionIdentifier> IGraphable.GraphableTransitionIdentifiers()
Returns
IGraphable.InstantiateFromResource(IGraphable)
Declaration
IGraphable IGraphable.InstantiateFromResource(IGraphable resource)
Parameters
Returns
Declaration
void IGraphable.PerformGraphableTransition(GraphableTransition transition)
Parameters
IGraphable.SetGraph(Object)
Declaration
void IGraphable.SetGraph(object graph)
Parameters
Type |
Name |
Description |
System.Object |
graph |
|
IGraphableEmbedContainer.EmbedGraphables(List<GraphableEmbedData>)
Declaration
void IGraphableEmbedContainer.EmbedGraphables(List<GraphableEmbedData> graphableEmbedDatas)
Parameters
Type |
Name |
Description |
System.Collections.Generic.List<GraphableEmbedData> |
graphableEmbedDatas |
|
IGraphableEmbedContainer.GraphableEmbedViewObjects
Declaration
IGraphableEmbedViewObject[] IGraphableEmbedContainer.GraphableEmbedViewObjects { get; }
Returns
IGraphableTransitionInvoker.BindGraphableTransitionInvokable(IGraphableTransitionInvokable)
Declaration
void IGraphableTransitionInvoker.BindGraphableTransitionInvokable(IGraphableTransitionInvokable invokable)
Parameters
IGraphableTransitionViewObjectContainer.BindGraphableTransitionViewObjectActivationListener(IGraphableTransitionViewObjectListener)
Declaration
void IGraphableTransitionViewObjectContainer.BindGraphableTransitionViewObjectActivationListener(IGraphableTransitionViewObjectListener listener)
Parameters
IGraphableTransitionViewObjectContainer.GraphableTransitionViewObjects
Declaration
IGraphableTransitionViewObject[] IGraphableTransitionViewObjectContainer.GraphableTransitionViewObjects { get; }
Returns
ITransitionContextViewController.Opaque
Declaration
bool ITransitionContextViewController.Opaque { get; }
Returns
Type |
Description |
System.Boolean |
|
ITransitionContextViewController.SetViewVisible(Boolean)
Declaration
void ITransitionContextViewController.SetViewVisible(bool visible)
Parameters
Type |
Name |
Description |
System.Boolean |
visible |
|
Implements