C# Unity将子对象添加到blendtree
我正在尝试制作一个脚本,它将接收动画列表并自动将它们添加到混合树中。我查看了混合树API,并得出以下结论:C# Unity将子对象添加到blendtree,c#,visual-studio,unity3d,animation,C#,Visual Studio,Unity3d,Animation,我正在尝试制作一个脚本,它将接收动画列表并自动将它们添加到混合树中。我查看了混合树API,并得出以下结论: using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEditor; using UnityEditor.Animations; public class AnimationSwitcher : MonoBehaviour { public List<
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using UnityEditor.Animations;
public class AnimationSwitcher : MonoBehaviour
{
public List<Motion> animations;
public Animator animator;
public BlendTree blendTree;
public void addMotions()
{
for (int i = 0; i < animations.Count; i++)
{
blendTree.AddChild(animations[i]);
}
}
}
使用系统集合;
使用System.Collections.Generic;
使用UnityEngine;
使用UnityEditor;
使用UnityEdit.Animations;
公共类动画师:单行为
{
公开列表动画;
公共动画师;
公共混合树;
公众动议(
{
对于(int i=0;i
我知道我必须使用animator组件,但对于如何使用它添加blendtree子级,我无法得到一个易读的答案。我曾尝试在编辑器中分配blendtree,但使用System.Collections也不起作用;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using UnityEditor.Animations;
public class AnimationSwitcher : MonoBehaviour
{
public List<Motion> animations;
public AnimatorController animator;
private BlendTree blendTree;
void Start()
{
animator.CreateBlendTreeInController("Active", out blendTree);
blendTree.AddChild(animations[0]);
}
public void addMotions()
{
for (int i = 0; i < animations.Count; i++)
{
blendTree.AddChild(animations[i]);
}
}
}
使用System.Collections.Generic;
使用UnityEngine;
使用UnityEditor;
使用UnityEdit.Animations;
公共类动画师:单行为
{
公开列表动画;
公共动画师控制动画师;
私人混合树混合树;
void Start()
{
animator.createBlendTreeInControl(“活动”,输出blendTree);
blendTree.AddChild(动画[0]);
}
公众动议(
{
对于(int i=0;i