/// <param name="isChild">является ли blendTree дочерним в клонированном BlendTree</param>
    private static BlendTree BlendTreeClone(BlendTree original, bool isChild)
    {
        BlendTree stateClone = new BlendTree
        {
            hideFlags = HideFlags.HideInHierarchy,
            name      = !isChild ? original.name + " clone" : original.name + additionalTextForChilds
        };

        stateClone.SetBlendType(original.GetBlendType());
        stateClone.SetUseAutomaticThresholds(original.GetUseAutomaticThresholds());
        stateClone.SetMaxThreshold(original.GetMaxThreshold());
        stateClone.SetMinThreshold(original.GetMinThreshold());
        stateClone.SetBlendEvent(original.GetBlendEvent());
        stateClone.SetBlendEventY(original.GetBlendEventY());

        for (int i = 0; i < original.GetChildCount(); i++)
        {
            Motion childMotion = original.GetMotion(i);
            if (childMotion is BlendTree)
            {
                childMotion = BlendTreeClone((BlendTree)childMotion, true);
            }

            stateClone.AddMotion(childMotion);
            stateClone.SetChildTimeScale(i, original.GetChildTimeScale(i));
            stateClone.SetChildTreshold(i, original.GetChildTreshold(i));
        }
        return(stateClone);
    }
Пример #2
0
        private static int FindMotionIndexOnBlendTree(BlendTree blendTree, Motion motion)
        {
            int childCount = blendTree.GetChildCount();

            for (int i = 0; i < childCount; i++)
            {
                if (blendTree.GetChildMotion(i) == motion)
                {
                    return(i);
                }
            }
            return(-1);
        }
Пример #3
0
        private void SetParameterValueRecursive(BlendTree blendTree, string parameterName, float parameterValue)
        {
            blendTree.SetInputBlendValue(parameterName, parameterValue);
            int childCount = blendTree.GetChildCount();

            for (int i = 0; i < childCount; i++)
            {
                BlendTree blendTree2 = blendTree.GetChildMotion(i) as BlendTree;
                if (!(blendTree2 == null))
                {
                    this.SetParameterValueRecursive(blendTree2, parameterName, parameterValue);
                }
            }
        }
Пример #4
0
        private void CreateNodeFromBlendTreeRecursive(BlendTree blendTree, Node parentNode)
        {
            Node node = this.CreateNode(blendTree, blendTree.name);

            if (parentNode)
            {
                node.parent = parentNode;
                Slot fromSlot = parentNode.AddOutputSlot(blendTree.name);
                Slot toSlot   = node.AddInputSlot((parentNode.motion as BlendTree).name);
                this.Connect(fromSlot, toSlot);
            }
            else
            {
                this.m_RootBlendTree = blendTree;
                this.m_RootNode      = node;
            }
            int childCount = blendTree.GetChildCount();

            for (int i = 0; i < childCount; i++)
            {
                Motion childMotion = blendTree.GetChildMotion(i);
                if (childMotion == null)
                {
                    this.CreateEmptySlot(node);
                }
                else if (childMotion is BlendTree)
                {
                    this.CreateNodeFromBlendTreeRecursive(childMotion as BlendTree, node);
                }
                else
                {
                    if (!(childMotion is AnimationClip))
                    {
                        throw new NotImplementedException("Unknown Motion type:" + childMotion.GetType());
                    }
                    this.CreateNodeFromAnimationClip(childMotion as AnimationClip, node);
                }
            }
        }