コード例 #1
0
    /// <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);
    }