Table of Contents

Class Node

Namespace
Lime
Assembly
Lime.dll

Scene tree element.

public abstract class Node : IDisposable, IAnimatorHost, IRenderChainBuilder, IAnimable, ICloneable
Inheritance
Node
Implements
Derived
Inherited Members
Extension Methods

Constructors

Node()

Initializes a new instance of node.

protected Node()

Fields

CreatedCount

public static int CreatedCount

Field Value

int

DirtyMask

TODO: Add summary

protected Node.DirtyFlags DirtyMask

Field Value

Node.DirtyFlags

FinalizedCount

public static int FinalizedCount

Field Value

int

HitTestTarget

Gets or sets the value that's indicating if the node responds the mouse/touch events.

public bool HitTestTarget

Field Value

bool

SceneLoaded

public static ThreadLocal<Node.SceneLoadedDelegate> SceneLoaded

Field Value

ThreadLocal<Node.SceneLoadedDelegate>

SceneLoading

public static ThreadLocal<Node.SceneLoadingDelegate> SceneLoading

Field Value

ThreadLocal<Node.SceneLoadingDelegate>

globallyFrozen

protected bool globallyFrozen

Field Value

bool

Properties

Ancestors

Enumerate all node's ancestors.

public IEnumerable<Node> Ancestors { get; }

Property Value

IEnumerable<Node>

AnimationFrame

Get or sets the current animation frame.

[Obsolete("Use AnimationUtils.SecondsToFrames(DefaultAnimation.Time)")]
public int AnimationFrame { get; set; }

Property Value

int

AnimationSpeed

Animation speed multiplier.

public float AnimationSpeed { get; set; }

Property Value

float

AnimationTime

Gets or sets time of current frame of default animation (in milliseconds).

[Obsolete("Use DefaultAnimation.Time")]
public double AnimationTime { get; set; }

Property Value

double

Animations

Gets the animations.

[YuzuMember]
[YuzuSerializeIf("NeedSerializeAnimations")]
public AnimationCollection Animations { get; }

Property Value

AnimationCollection

Animators

Collection of Animators.

[YuzuMember]
public AnimatorList Animators { get; }

Property Value

AnimatorList

AsNode3D

Cached result of cast to Node3D.

public Node3D AsNode3D { get; }

Property Value

Node3D

AsWidget

Cached result of cast to widget.

public Widget AsWidget { get; }

Property Value

Widget

Components

Gets collection of node Components. If a node component of certain type shouldn't be serialized mark the type with NodeComponentDontSerializeAttribute. In case a node component of certain type should be removed when cooking assets use RemoveOnAssetCookAttribute.

[YuzuMember]
public NodeComponentCollection Components { get; }

Property Value

NodeComponentCollection

CompoundPostPresenter

Makes the post presenter compound and returns it.

public CompoundPresenter CompoundPostPresenter { get; }

Property Value

CompoundPresenter

CompoundPresenter

Makes the presenter compound and returns it.

public CompoundPresenter CompoundPresenter { get; }

Property Value

CompoundPresenter

ContentsPath

Denotes the path to the external scene. If this path isn't null during node loading, the node children are replaced by the external scene nodes.

[YuzuMember]
[Validation.DefaultCharset]
public string ContentsPath { get; set; }

Property Value

string

CurrentAnimation

Name of last started marker of default animation. Is set to null by default.

public string CurrentAnimation { get; set; }

Property Value

string

DefaultAnimation

Returns the first animation in the animation collection or creates an animation if the collection is empty.

public Animation DefaultAnimation { get; }

Property Value

Animation

Descendants

Gets a DFS-enumeration of all descendant nodes not including itself.

public IEnumerable<Node> Descendants { get; }

Property Value

IEnumerable<Node>

EffectiveAnimationSpeed

Gets absolute animation speed that's product of self animation speed multiplied by parent absolute animation speed. EffectiveAnimationSpeed = AnimationSpeed * Parent.EffectiveAnimationSpeed.

public float EffectiveAnimationSpeed { get; }

Property Value

float

FirstChild

Gets the cached reference to the first children node. Use it for fast iteration through nodes collection in a performance-critical code.

public Node FirstChild { get; }

Property Value

Node

Folders

Gets the folder descriptors.

[YuzuMember]
public FolderList Folders { get; }

Property Value

FolderList

Frozen

public bool Frozen { get; set; }

Property Value

bool

Gestures

Gets the gesture recognizers.

public GestureList Gestures { get; }

Property Value

GestureList

GloballyFrozen

public bool GloballyFrozen { get; }

Property Value

bool

Id

A node identifier. May be non-unique.

[YuzuMember]
[Validation.DefaultCharset]
public string Id { get; set; }

Property Value

string

IsRunning

Returns true if this node is running animation.

[Obsolete("Use DefaultAnimation.IsRunning")]
public bool IsRunning { get; set; }

Property Value

bool

IsStopped

Returns true if this node isn't running animation.

[Obsolete("Use !DefaultAnimation.IsRunning")]
public bool IsStopped { get; set; }

Property Value

bool

LateTasks

Tasks that are called after Update.

public TaskList LateTasks { get; }

Property Value

TaskList

Layer

Gets or sets Z-order (the rendering order). 0 - inherit Z-order from the parent node. 1 - the lowest, (RenderChain.LayerCount - 1) - the topmost.

public int Layer { get; set; }

Property Value

int

Manager

Gets a manager of this node.

public NodeManager Manager { get; }

Property Value

NodeManager

Markers

Markers of default animation.

[Obsolete("Use DefaultAnimation.Markers")]
public MarkerList Markers { get; }

Property Value

MarkerList

NextSibling

Gets the cached reference to the next node in the NodeList. Use it for fast iteration through nodes collection in a performance-critical code.

public Node NextSibling { get; }

Property Value

Node

Nodes

Child nodes. For enumerating all descendants use Descendants.

[YuzuMember]
[YuzuSerializeIf("ShouldSerializeNodes")]
public NodeList Nodes { get; }

Property Value

NodeList

Parent

Gets the parent node.

public Node Parent { get; }

Property Value

Node

PostPresenter

The presenter used for rendering the node after rendering its children.

public IPresenter PostPresenter { get; set; }

Property Value

IPresenter

Presenter

The presenter used for rendering and hit-testing the node. TODO: Add Add/RemovePresenter methods. Remove CompoundPresenter property and Presenter setter.

public IPresenter Presenter { get; set; }

Property Value

IPresenter

RenderChainBuilder

Gets the render chain builder.

public IRenderChainBuilder RenderChainBuilder { get; set; }

Property Value

IRenderChainBuilder

SelfAndDescendants

Gets a DFS-enumeration of all descendant nodes starting with itself.

public IEnumerable<Node> SelfAndDescendants { get; }

Property Value

IEnumerable<Node>

Tag

Custom data. Can be set via Tangerine (this way it will contain path to external scene). Can't use obsolete attribute because of Yuzu Generated Binary Deserializers. But its obsolete, don't use it. Use Node Components instead.

[YuzuMember]
public string Tag { get; set; }

Property Value

string

TangerineFlags

Flags that are used by Tangerine.

[YuzuMember]
public TangerineFlags TangerineFlags { get; set; }

Property Value

TangerineFlags

Tasks

Tasks that are called before Update.

public TaskList Tasks { get; }

Property Value

TaskList

Trigger

May contain the marker id of the default animation. When an animation hits a trigger keyframe, it automatically runs the child animation from the given marker id.

public string Trigger { get; set; }

Property Value

string

Updated

Called after Update.

public UpdateHandler Updated { get; set; }

Property Value

UpdateHandler

Updating

Called before Update.

public UpdateHandler Updating { get; set; }

Property Value

UpdateHandler

UserData

Custom data. Can only be set programmatically.

public object UserData { get; set; }

Property Value

object

Methods

AddNode(Node)

Adds provided node to the lowermost layer of this node (i.e. it will be covered by other nodes). Provided node shouldn't belong to any node (check for Parent == null and use Unlink if needed).

public void AddNode(Node node)

Parameters

node Node

A child node.

AddSelfAndChildrenToRenderChain(RenderChain, int)

Add this node and it children to the render chain.

public void AddSelfAndChildrenToRenderChain(RenderChain chain, int layer)

Parameters

chain RenderChain

A render chain into which should be added.

layer int

A node layer.

AddSelfToRenderChain(RenderChain, int)

Add this node to the render chain.

protected void AddSelfToRenderChain(RenderChain chain, int layer)

Parameters

chain RenderChain

A render chain into which should be added.

layer int

A node layer.

AddToNode(Node)

Adds this node to the lowermost layer of provided node (i.e. it will be covered by other nodes). This node shouldn't belong to any node (check for Parent == null and use Unlink if needed).

public void AddToNode(Node node)

Parameters

node Node

A parent node.

AddToRenderChain(RenderChain)

Decides what descendant nodes should be added to render chain and under which conditions. This includes children Nodes as well as this Node itself. i.e. if you want Render() of this node to be called you should invoke AddSelfToRenderChain in AddToRenderChain override.

public abstract void AddToRenderChain(RenderChain chain)

Parameters

chain RenderChain

CleanDirtyFlags(DirtyFlags)

protected bool CleanDirtyFlags(Node.DirtyFlags mask)

Parameters

mask Node.DirtyFlags

Returns

bool

Clone()

public virtual Node Clone()

Returns

Node

CloneRaw()

protected Node CloneRaw()

Returns

Node

DescendantOf(Node)

Checks if this node is a descendant of the specified node.

public bool DescendantOf(Node node)

Parameters

node Node

A parent node.

Returns

bool

True if this node is a descendant of the specified node, otherwise false.

Dispose()

Disposes the node and all of it components, animations, tasks, etc...

public virtual void Dispose()

FindNode(string)

Searches for node with provided path or id in this node's descendants. Throws an exception if sought-for node doesn't exist.

This function is thread safe.

public Node FindNode(string path)

Parameters

path string

Id or path of Node. Path can be incomplete (i.e. for path Root/Human/Head/Eye Human or Head can be ommited).

Returns

Node

Find<T>(string)

Searches for node with provided path or id in this node's descendants. Throws an exception if sought-for node doesn't exist.

This function is thread safe.

public T Find<T>(string path) where T : Node

Parameters

path string

Id or path of Node. Path can be incomplete (i.e. for path Root/Human/Head/Eye Human or Head can be ommited).

Returns

T

Type Parameters

T

Type of sought-for node.

Find<T>(string, params object[])

Searches for node with provided path or id in this node's descendants. Returns null if sought-for node doesn't exist.

This function is thread safe.

public T Find<T>(string format, params object[] args) where T : Node

Parameters

format string

Id or path of Node. Path can be incomplete (i.e. for path Root/Human/Head/Eye Human or Head can be ommited).

args object[]

Returns

T

Type Parameters

T

Type of sought-for node.

ForceFilterNodes()

[Obsolete("Do not use.")]
protected void ForceFilterNodes()

GetRenderObject()

TODO: Add summary.

protected virtual RenderObject GetRenderObject()

Returns

RenderObject

GetRoot()

Gets the root node.

public Node GetRoot()

Returns

Node

The root node.

GetTangerineFlag(TangerineFlags)

Retrieves the value of the specified Tangerine flag.

public bool GetTangerineFlag(TangerineFlags flag)

Parameters

flag TangerineFlags

Returns

bool

HasGestures()

Checks if the node has at least one gesture recognizer.

public bool HasGestures()

Returns

bool

True is the node has at least one gesture recognizer, otherwise false.

IsDirty(DirtyFlags)

TODO: Add summary

protected bool IsDirty(Node.DirtyFlags mask)

Parameters

mask Node.DirtyFlags

Returns

bool

IsMouseOver()

public bool IsMouseOver()

Returns

bool

IsMouseOverThisOrDescendant()

public bool IsMouseOverThisOrDescendant()

Returns

bool

IsNotDecorated()

public virtual bool IsNotDecorated()

Returns

bool

Load(Stream, string, Node, bool)

Loads node from given stream under Current

public static Node Load(Stream stream, string path, Node instance = null, bool ignoreExternals = false)

Parameters

stream Stream

Stream with serialized Node.

path string

Path in asset bundle.

instance Node

Existing instance of node. If set to

null
new instance is created.
ignoreExternals bool

Do not load prefabs.

Returns

Node

Instance of Node loaded from given path.

Load(string, Node, bool)

Loads node by given path under Current

public static Node Load(string path, Node instance = null, bool ignoreExternals = false)

Parameters

path string

Path in asset bundle.

instance Node

Existing instance of node. If set to

null
new instance is created.
ignoreExternals bool

Do not load prefabs.

Returns

Node

Instance of Node loaded from given path.

LoadExternalScenes()

public virtual void LoadExternalScenes()

Load<T>(string, T, bool)

Loads node by given path under Current

public static T Load<T>(string path, T instance = null, bool ignoreExternals = false) where T : Node

Parameters

path string

Path in asset bundle.

instance T

Existing instance of node. If set to

null
new instance is created.
ignoreExternals bool

Do not load prefabs.

Returns

T

Instance of Node loaded from given path.

Type Parameters

T

Expected concrete type of Node.

NeedSerializeAnimations()

public bool NeedSerializeAnimations()

Returns

bool

NotifyOnBuilt()

public void NotifyOnBuilt()

NotifyOnBuiltSuperficial()

public void NotifyOnBuiltSuperficial()

OnAfterSerialization()

public void OnAfterSerialization()

OnBeforeSerialization()

public void OnBeforeSerialization()

OnBuilt()

protected virtual void OnBuilt()

OnParentChanged(Node)

Occurs when Parent property changes.

protected virtual void OnParentChanged(Node oldParent)

Parameters

oldParent Node

OnTrigger(string, object, double)

Invokes when the trigger property has been changed by animation.

public virtual void OnTrigger(string property, object value, double animationTimeCorrection = 0)

Parameters

property string

A property name.

value object

A new property value.

animationTimeCorrection double

An animation time correction.

PartialHitTest(ref HitTestArgs)

protected virtual bool PartialHitTest(ref HitTestArgs args)

Parameters

args HitTestArgs

Returns

bool

PreloadAssets()

Loads all textures, fonts and animators for this node and for all its descendants. Forces reloading of textures if they are null.

public void PreloadAssets()

PropagateDirtyFlags(DirtyFlags)

Propagates dirty flags to all descendants by provided mask.

protected void PropagateDirtyFlags(Node.DirtyFlags mask = (Node.DirtyFlags)-1)

Parameters

mask Node.DirtyFlags

PropagateParentBoundsChanged()

protected void PropagateParentBoundsChanged()

PropagateParentBoundsChangedHelper()

protected void PropagateParentBoundsChangedHelper()

PushNode(Node)

Adds provided node to the topmost layer of this node (i.e. it will cover other nodes). Provided node shouldn't belong to any node (check for Parent == null and use Unlink if needed).

public void PushNode(Node node)

Parameters

node Node

A child node.

PushToNode(Node)

Adds this node to the topmost layer of provided node (i.e. it will cover other nodes). This node shouldn't belong to any node (check for Parent == null and use Unlink if needed).

public void PushToNode(Node node)

Parameters

node Node

A parent node.

RecalcGloballyFrozen()

protected virtual void RecalcGloballyFrozen()

RemoveAnimatorsForExternalAnimations()

public void RemoveAnimatorsForExternalAnimations()

ReplaceContent(Node)

public void ReplaceContent(Node content)

Parameters

content Node

ResolveScenePath(string)

Returns path to scene if it exists in bundle. Returns null otherwise. Throws exception if there is more than one scene file with such path.

public static string ResolveScenePath(string path)

Parameters

path string

Returns

string

RunAnimation(string, string)

Runs animation with provided Id and provided marker. Throws an exception if sought-for animation or marker doesn't exist. Returns this (to use with yield return)

public Animation RunAnimation(string markerId, string animationId = null)

Parameters

markerId string
animationId string

Returns

Animation

SameOrDescendantOf(Node)

Checks if this node is the specified node or a descendant of.

public bool SameOrDescendantOf(Node node)

Parameters

node Node

A parent node.

Returns

bool

if this node is the specified node or a descendant of, otherwise false.

Save(string, Format)

Saves node to a file.

public void Save(string path, Persistence.Format format)

Parameters

path string

Path to the file.

format Persistence.Format

Persistence.Format

Save(string, Stream, Format)

Saves node to a stream.

public void Save(string path, Stream stream, Persistence.Format format)

Parameters

path string

Path to the file. Required for correct asset path shrink or expand for relative assets.

stream Stream

The stream.

format Persistence.Format

Persistence.Format

SetTangerineFlag(TangerineFlags, bool)

Sets the value for the specified Tangerine flag.

public void SetTangerineFlag(TangerineFlags flag, bool value)

Parameters

flag TangerineFlags

A Tangerine flag

value bool

A value to set.

ShouldSerializeNodes()

public bool ShouldSerializeNodes()

Returns

bool

StaticScale(float, bool)

TODO: Translate Этот метод масштабирует позицию и размер данного нода и всех его потомков. Метод полезен для адаптирования сцены под экраны с нестандартным DPI. Если позиция или размер виджета анинимированы, то ключи анимации также подвергаются соответствующему преобразованию. Для текстовых виджетов, размер шрифта масштабируется.

public virtual void StaticScale(float ratio, bool roundCoordinates)

Parameters

ratio float
roundCoordinates bool

Если true, то после масштабирования виджета, его размер округляется, а сам виджет сдвигается таким образом, чтобы его левый верхний угол (точка (0,0) в локальных координатах виджета) перешел в целочисленную позицию.

ToString()

Returns the string representation of this Node.

public override string ToString()

Returns

string

TriggerMultipleAnimations(string, double)

TODO: Add summary.

protected void TriggerMultipleAnimations(string trigger, double animationTimeCorrection = 0)

Parameters

trigger string
animationTimeCorrection double

TryFindNode(string)

Searches for node with provided path or id in this node's descendants. Returns null if sought-for node doesn't exist.

This function is thread safe.

public Node TryFindNode(string path)

Parameters

path string

Id or path of Node. Path can be incomplete (i.e. for path Root/Human/Head/Eye Human or Head can be ommited).

Returns

Node

TryFind<T>(string)

Searches for node with provided path or id in this node's descendants. Returns null if sought-for node doesn't exist.

This function is thread safe.

public T TryFind<T>(string path) where T : Node

Parameters

path string

Id or path of Node. Path can be incomplete (i.e. for path Root/Human/Head/Eye Human or Head can be ommited).

Returns

T

Type Parameters

T

Type of sought-for node.

TryFind<T>(string, params object[])

Searches for node with provided path or id in this node's descendants. Returns null if sought-for node doesn't exist.

This function is thread safe.

public T TryFind<T>(string format, params object[] args) where T : Node

Parameters

format string

Id or path of Node. Path can be incomplete (i.e. for path Root/Human/Head/Eye Human or Head can be ommited).

args object[]

Returns

T

Type Parameters

T

Type of sought-for node.

TryFind<T>(string, out T)

Searches for node with provided path or id in this node's descendants. Returns null if sought-for node doesn't exist.

This function is thread safe.

public bool TryFind<T>(string path, out T node) where T : Node

Parameters

path string

Id or path of Node. Path can be incomplete (i.e. for path Root/Human/Head/Eye Human or Head can be ommited).

node T

Returns

bool

Type Parameters

T

Type of sought-for node.

TryRunAnimation(string, string, double)

Runs animation with provided Id and provided marker. Returns false if sought-for animation or marker doesn't exist.

public bool TryRunAnimation(string markerId, string animationId = null, double animationTimeCorrection = 0)

Parameters

markerId string
animationId string
animationTimeCorrection double

Returns

bool

Removes this node from children of the parent node.

public void Unlink()

UnlinkAndDispose()

Removes this node from children of the parent node and disposes it.

public void UnlinkAndDispose()

UpdateAncestorBoundingRect(Widget)

public virtual void UpdateAncestorBoundingRect(Widget ancestor)

Parameters

ancestor Widget

Events

AnimationStopped

Is invoked after default animation has been stopped (e.g. hit "Stop" marker). Note: DefaultAnimation.Stopped will be set to null after invocation or after RunAnimation call. The correct usage is to call RunAnimation first and then apply any required AnimationStopped handlers.

public event Action AnimationStopped

Event Type

Action

Awoke

Occurs at node first update.

public event Action<Node> Awoke

Event Type

Action<Node>