2D animator component that plays a single AnimationClip2D directly, without a state machine.

直接播放单个 2D 动画片段的组件,无需状态机。

层级

  • Animator2DBase
    • AnimatorClip2D

构造函数

属性

Extra data of the node.

组件的额外数据。IDE内部使用。

_id: number

Unique identifier for the component.

组件的唯一标识。

_singleton: boolean

Whether the component is a singleton, meaning only one instance of this type of script can be added to the same node.

是否为单例,即同一个节点只能添加此类型的脚本一次。

owner: Node

Gets the owner Node to which the component belongs.

获取组件所属的 Node 节点。

runInEditor: boolean

Whether the script can run in the IDE environment.

是否可以在 IDE 环境中运行。

scriptPath: string

The path of the script file.

脚本文件的路径。

访问器

方法

  • 参数

    • flag: number

      The hide flag to check for.

    返回 boolean

    Checks if the component has a specific hide flag set.

    检查组件是否设置了特定的隐藏标志。

  • 返回 void

    Called after the component is added to a node. Unlike Awake, onAdded is called even if the node is not active.

    组件被添加到节点后调用,与 onAwake 不同的是,即使节点未激活也会调用 onAdded。

  • 返回 void

    Executed after the component is activated. At this point, all nodes and components have been created. This method is executed only once.

    组件被激活后执行,此时所有节点和组件均已创建完毕,此方法只执行一次。

  • 返回 void

    Executed when the component is disabled, such as when the node is removed from the stage.

    组件被禁用时执行,比如从节点从舞台移除后。

  • 返回 void

    Executed after the component is enabled, such as when the node is added to the stage.

    组件被启用后执行,比如节点被添加到舞台后。

  • 返回 void

    Executed every frame during the late update phase, after the update phase.

    每帧更新时执行,在 late update 阶段,update 阶段之后。

  • 返回 void

    Resets the component's parameters to their default values. If this function is implemented, the component will be reset and automatically recycled for future use. If not reset, it will not be recycled for reuse.

    将组件的参数重置为默认值。如果实现了这个函数,组件将被重置并自动回收到对象池,方便下次复用。 如果没有重置,则不会进行回收复用。

  • 返回 void

    Executed once, before the first update.

    在第一次执行 update 之前执行,只会执行一次。

  • 返回 void

    Executed every frame during the update phase. Avoid writing complex loop logic or using the getComponent method here.

    每帧更新时执行,在 update 阶段。尽量不要在这里写大循环逻辑或使用 getComponent 方法。

  • 参数

    • 可选normalizedTime: number

      0~1, omit to start from 0

    返回 void

    Play the clip from start or from the given normalized time.

    播放片段,可从开头或指定归一化时间开始。