/// <summary> /// 把 BlendTree 转换为 AssetBlendTree /// </summary> /// <param name="originBlendTree"></param> /// <param name="assetBlendTree"></param> private void TransBlendTree(BlendTree originBlendTree, AssetBlendTree assetBlendTree, string blendTreeName) { assetBlendTree.stateName = blendTreeName; assetBlendTree.parameter = originBlendTree.blendParameter; if (originBlendTree.blendType == BlendTreeType.Simple1D) { assetBlendTree.blendTreeType = AssetBlendTree.BlendTreeType._1D; // 目前只支持1D混合树 } else { Debug.LogError("not support blendTree type except Simple1D"); return; } ChildMotion[] originChilds = originBlendTree.children; assetBlendTree.motions = new AssetStateController.Motion[originChilds.Length]; for (int i = 0; i < originChilds.Length; i++) { AssetStateController.Motion newMotion = new AssetStateController.Motion(); AnimationClip clip = (originChilds[i].motion as AnimationClip); // 混合树子节点 转换为clip类型 newMotion.blendTreeType = assetBlendTree.blendTreeType; newMotion.clip = clip; newMotion.threshold = originChilds[i].threshold; newMotion.speed = originChilds[i].timeScale; assetBlendTree.motions[i] = newMotion; } assetBlendTree.Sort(); // 按照threshold排序 }
private void OnEnable() { m_Target = target as AssetBlendTree; m_Motions = serializedObject.FindProperty("motions"); m_Param = serializedObject.FindProperty("parameter"); m_Type = serializedObject.FindProperty("blendTreeType"); m_Name = serializedObject.FindProperty("stateName"); m_Target.Sort(); m_Target.SetBlendTreeType(); }