UnityEditor.TransitionPreview.CreateController C# (CSharp) Method

CreateController() private method

private CreateController ( ) : void
return void
        private void CreateController()
        {
            if (((this.m_Controller == null) && (this.m_AvatarPreview != null)) && ((this.m_AvatarPreview.Animator != null) && (this.m_RefTransition != null)))
            {
                this.m_LayerIndex = 0;
                this.m_Controller = new AnimatorController();
                this.m_Controller.pushUndo = false;
                this.m_Controller.hideFlags = HideFlags.HideAndDontSave;
                this.m_Controller.AddLayer("preview");
                bool flag = true;
                if (this.m_LayerMask != null)
                {
                    for (AvatarMaskBodyPart part = AvatarMaskBodyPart.Root; (part < AvatarMaskBodyPart.LastBodyPart) && flag; part += 1)
                    {
                        if (!this.m_LayerMask.GetHumanoidBodyPartActive(part))
                        {
                            flag = false;
                        }
                    }
                    if (!flag)
                    {
                        this.m_Controller.AddLayer("Additionnal");
                        this.m_LayerIndex++;
                        AnimatorControllerLayer[] layers = this.m_Controller.layers;
                        layers[this.m_LayerIndex].avatarMask = this.m_LayerMask;
                        this.m_Controller.layers = layers;
                    }
                }
                this.m_StateMachine = this.m_Controller.layers[this.m_LayerIndex].stateMachine;
                this.m_StateMachine.pushUndo = false;
                this.m_StateMachine.hideFlags = HideFlags.HideAndDontSave;
                this.m_SrcMotion = this.m_RefSrcState.motion;
                this.m_DstMotion = this.m_RefDstState.motion;
                this.m_ParameterMinMax.Clear();
                if ((this.m_SrcMotion != null) && (this.m_SrcMotion is BlendTree))
                {
                    BlendTree srcMotion = this.m_SrcMotion as BlendTree;
                    for (int i = 0; i < srcMotion.recursiveBlendParameterCount; i++)
                    {
                        string recursiveBlendParameter = srcMotion.GetRecursiveBlendParameter(i);
                        if (this.m_Controller.IndexOfParameter(recursiveBlendParameter) == -1)
                        {
                            this.m_Controller.AddParameter(recursiveBlendParameter, AnimatorControllerParameterType.Float);
                            this.m_ParameterMinMax.Add(new Vector2(srcMotion.GetRecursiveBlendParameterMin(i), srcMotion.GetRecursiveBlendParameterMax(i)));
                        }
                    }
                }
                if ((this.m_DstMotion != null) && (this.m_DstMotion is BlendTree))
                {
                    BlendTree dstMotion = this.m_DstMotion as BlendTree;
                    for (int j = 0; j < dstMotion.recursiveBlendParameterCount; j++)
                    {
                        string name = dstMotion.GetRecursiveBlendParameter(j);
                        int num3 = this.m_Controller.IndexOfParameter(name);
                        if (num3 == -1)
                        {
                            this.m_Controller.AddParameter(name, AnimatorControllerParameterType.Float);
                            this.m_ParameterMinMax.Add(new Vector2(dstMotion.GetRecursiveBlendParameterMin(j), dstMotion.GetRecursiveBlendParameterMax(j)));
                        }
                        else
                        {
                            Vector2 vector = this.m_ParameterMinMax[num3];
                            Vector2 vector2 = this.m_ParameterMinMax[num3];
                            this.m_ParameterMinMax[num3] = new Vector2(Mathf.Min(dstMotion.GetRecursiveBlendParameterMin(j), vector[0]), Mathf.Max(dstMotion.GetRecursiveBlendParameterMax(j), vector2[1]));
                        }
                    }
                }
                this.m_SrcState = this.m_StateMachine.AddState(this.m_RefSrcState.name);
                this.m_SrcState.pushUndo = false;
                this.m_SrcState.hideFlags = HideFlags.HideAndDontSave;
                this.m_DstState = this.m_StateMachine.AddState(this.m_RefDstState.name);
                this.m_DstState.pushUndo = false;
                this.m_DstState.hideFlags = HideFlags.HideAndDontSave;
                this.CopyStateForPreview(this.m_RefSrcState, ref this.m_SrcState);
                this.CopyStateForPreview(this.m_RefDstState, ref this.m_DstState);
                this.m_Transition = this.m_SrcState.AddTransition(this.m_DstState, true);
                this.m_Transition.pushUndo = false;
                this.m_Transition.hideFlags = HideFlags.DontSave;
                this.CopyTransitionForPreview(this.m_RefTransition, ref this.m_Transition);
                this.DisableIKOnFeetIfNeeded();
                AnimatorController.SetAnimatorController(this.m_AvatarPreview.Animator, this.m_Controller);
                this.m_Controller.OnAnimatorControllerDirty = (Action) Delegate.Combine(this.m_Controller.OnAnimatorControllerDirty, new Action(this, (IntPtr) this.ControllerDirty));
            }
        }