UnityEngine中Animator相关类的说明

----------------------------------------------------------------------

Animator

这个单独写,比较多

AnimationClip 
有个SampleAnimation,可以让Go采样到某个动画时间(直接设置那个时间的姿势)
有个只读的frameRate,帧率,采样频率(暂时不知道有什么应用)

AnimatorClipInfo
只包含AnimationClip和权重信息

AnimationClipPair
包含原始clip和目标clip,暂时不知道有什么用

AnimatorControllerParameter
貌似就是用来控制动画改变条件的
--------------------------------------------------------------------
AnimatorOverrideController
动态替换状态用,不重启动画状态机
AnimatorOverrideController is used to override clips from a controller to specialize some animations for a given avatar.Swapping Animator.runtimeAnimatorController with an AnimatorOverrideController based on the same AnimatorController at runtime doesn't reset state machine's current state.

代码
Animator animator = GetComponent<Animator>();
AnimatorOverrideController overrideController = new AnimatorOverrideController();
animator.runtimeAnimatorController = overrideController;
--------------------------------------------------------------------
AnimatorStateInfo
可以通过Animator获取


AnimatorTransitionInfo
可以通过Animator获取
--------------------------------------------------------------------
AnimatorUtility
里面有重要方法
public static void OptimizeTransformHierarchy(GameObject go, string[] exposedTransforms);

This function will remove all transform hierarchy under GameObject, the animator will write directly 

transform matrices into the skin mesh matrices saving alot of CPU cycles.

第一个方法会把骨骼transform去掉,参数exposedTransforms是保留的骨骼transform名称,被保留的每个transform
会直接绑定到当前gameobject下

public static void DeoptimizeTransformHierarchy(GameObject go);
与第一个函数功能相反,恢复原样

这两个函数的调用都会引起Animator重建
A call to this function at runtime will re-initialize the animator.
--------------------------------------------------------------------

AnimationCurve 代码修改动画曲线时用,貌似很少用手动修改动画曲线
constructor(name: string); constructor(); constructor(csNode?: CS.UnityEngine.GameObject, followCSActiveInHierarchy?: boolean, isCanvas?: boolean); constructor(arg1?: CS.UnityEngine.GameObject | string, followCSActiveInHierarchy: boolean = false, isCanvas: boolean = false) { let name: string | undefined = undefined; if (typeof arg1 === "string") { name = arg1; } super(name); let needSync = false; let csNode: CS.UnityEngine.GameObject | undefined; if (typeof arg1 === "string") { csNode = Node.newCSNode(arg1); } else { csNode = arg1; if (csNode) { needSync = true; if (followCSActiveInHierarchy) { this.activeInHierarchy = csNode.activeInHierarchy; } } } if (!csNode) { csNode = Node.newCSNode("cc_unknown_node"); } this.cs = csNode; this.active = csNode.activeSelf; let newProgressBarComp: ProgressBar | null = null; { if (this.hasCSComponentByCS(CS.UnityEngine.RectTransform)) { this.addComponent("cc.UITransform"); } // init component if (this.hasCSComponentByCS(CS.UnityEngine.SpriteRenderer)) { const spriteCom = this.addComponent("cc.Sprite") as Sprite; if (spriteCom) { spriteCom.initFromExistsCSNode(); } } if (this.hasCSComponentByCS(CS.UnityEngine.UI.Button)) { this.addComponent("cc.Button"); } if (this.hasCSComponentByCS(CS.TMPro.TextMeshPro) || this.hasCSComponentByCS(CS.UnityEngine.UI.Text)) { this.addComponent("cc.Label"); } if (this.hasCSComponentByCS(CS.Bridge.ProgressBarConfig)) { newProgressBarComp = this.addComponent("cc.ProgressBar") as ProgressBar; } if (this.hasCSComponentByCS(CS.UnityEngine.Animator)) { this.addComponent("cc.Animation") as Animation; } if (this.hasCSComponentByCS(CS.UnityEngine.TrailRenderer)) { const comp = this.addComponent("cc.MotionStreak") as MotionStreak; comp.cs = this.getCSComponentByCS(CS.UnityEngine.TrailRenderer)!; } if ( this.hasCSComponentByCS(CS.UnityEngine.UI.HorizontalLayoutGroup) || this.hasCSComponentByCS(CS.UnityEngine.UI.VerticalLayoutGroup) || this.hasCSComponentByCS(CS.UnityEngine.UI.GridLayoutGroup) ) { this._hasCSLayoutGroupComponent = true; } } if (needSync) { this._syncUnityNodeStatusToNode(isCanvas); } this._syncCSHierarchy(false, followCSActiveInHierarchy); if (newProgressBarComp) { newProgressBarComp.initByCSProgressBarConfig(this, this.getCSComponentByCS(CS.Bridge.ProgressBarConfig)!); } // eslint-disable-next-line @typescript-eslint/no-unused-expressions this.uuid; // refresh uuid this.on(NodeEventType.ACTIVE_IN_HIERARCHY_CHANGED, (node: Node) => { this._setActivateNode(node.active); // eslint-disable-next-line @typescript-eslint/no-unused-expressions this.uuid; // refresh uuid }); this.on(NodeEventType.COMPONENT_ADDED, (com: Component) => { // 清除缓存 this._lastUITransform = undefined; this._lastSprite = undefined; this._lastMask = undefined; this._lastLrot = null; this._markRenderOrderDirty(); }); }帮我解释一下这段代码
03-08
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值