Пример #1
0
        /// <summary>
        /// New way to create sub-state machines without destroying what exists first.
        /// </summary>
        protected override void CreateStateMachine()
        {
            int rLayerIndex = mMotionLayer._AnimatorLayerIndex;
            MotionController rMotionController = mMotionController;

            UnityEditor.Animations.AnimatorController lController = null;

            Animator lAnimator = rMotionController.Animator;

            if (lAnimator == null)
            {
                lAnimator = rMotionController.gameObject.GetComponent <Animator>();
            }
            if (lAnimator != null)
            {
                lController = lAnimator.runtimeAnimatorController as UnityEditor.Animations.AnimatorController;
            }
            if (lController == null)
            {
                return;
            }

            while (lController.layers.Length <= rLayerIndex)
            {
                UnityEditor.Animations.AnimatorControllerLayer lNewLayer = new UnityEditor.Animations.AnimatorControllerLayer();
                lNewLayer.name         = "Layer " + (lController.layers.Length + 1);
                lNewLayer.stateMachine = new UnityEditor.Animations.AnimatorStateMachine();
                lController.AddLayer(lNewLayer);
            }

            UnityEditor.Animations.AnimatorControllerLayer lLayer = lController.layers[rLayerIndex];

            UnityEditor.Animations.AnimatorStateMachine lLayerStateMachine = lLayer.stateMachine;

            UnityEditor.Animations.AnimatorStateMachine lSSM_37924 = MotionControllerMotion.EditorFindSSM(lLayerStateMachine, "BasicWalkRunPivot-SM");
            if (lSSM_37924 == null)
            {
                lSSM_37924 = lLayerStateMachine.AddStateMachine("BasicWalkRunPivot-SM", new Vector3(408, -1056, 0));
            }

            UnityEditor.Animations.AnimatorState lState_38400 = MotionControllerMotion.EditorFindState(lSSM_37924, "Unarmed BlendTree");
            if (lState_38400 == null)
            {
                lState_38400 = lSSM_37924.AddState("Unarmed BlendTree", new Vector3(312, 72, 0));
            }
            lState_38400.speed  = 1f;
            lState_38400.mirror = false;
            lState_38400.tag    = "";

            UnityEditor.Animations.BlendTree lM_25576 = MotionControllerMotion.EditorCreateBlendTree("Blend Tree", lController, rLayerIndex);
            lM_25576.blendType       = UnityEditor.Animations.BlendTreeType.Simple1D;
            lM_25576.blendParameter  = "InputMagnitude";
            lM_25576.blendParameterY = "InputX";
#if !(UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 || UNITY_5_0 || UNITY_5_1 || UNITY_5_2 || UNITY_5_3)
            lM_25576.useAutomaticThresholds = false;
#endif
            lM_25576.AddChild(MotionControllerMotion.EditorFindAnimationClip("Assets/ootii/Assets/MotionController/Content/Animations/Humanoid/Idling/unity_Idle_IdleToIdlesR.fbx", "IdlePose"), 0f);
            lM_25576.AddChild(MotionControllerMotion.EditorFindAnimationClip("Assets/ootii/Assets/MotionController/Content/Animations/Humanoid/Walking/unity_WalkFWD_v2.fbx", "WalkForward"), 0.5f);
            lM_25576.AddChild(MotionControllerMotion.EditorFindAnimationClip("Assets/ootii/Assets/MotionController/Content/Animations/Humanoid/Running/RunForward_v2.fbx", "RunForward"), 1f);
            lState_38400.motion = lM_25576;

            UnityEditor.Animations.AnimatorStateTransition lAnyTransition_38110 = MotionControllerMotion.EditorFindAnyStateTransition(lLayerStateMachine, lState_38400, 0);
            if (lAnyTransition_38110 == null)
            {
                lAnyTransition_38110 = lLayerStateMachine.AddAnyStateTransition(lState_38400);
            }
            lAnyTransition_38110.isExit              = false;
            lAnyTransition_38110.hasExitTime         = false;
            lAnyTransition_38110.hasFixedDuration    = true;
            lAnyTransition_38110.exitTime            = 0.75f;
            lAnyTransition_38110.duration            = 0.25f;
            lAnyTransition_38110.offset              = 0f;
            lAnyTransition_38110.mute                = false;
            lAnyTransition_38110.solo                = false;
            lAnyTransition_38110.canTransitionToSelf = true;
            lAnyTransition_38110.interruptionSource  = (UnityEditor.Animations.TransitionInterruptionSource) 0;
            for (int i = lAnyTransition_38110.conditions.Length - 1; i >= 0; i--)
            {
                lAnyTransition_38110.RemoveCondition(lAnyTransition_38110.conditions[i]);
            }
            lAnyTransition_38110.AddCondition(UnityEditor.Animations.AnimatorConditionMode.Equals, 3050f, "L" + rLayerIndex + "MotionPhase");
            lAnyTransition_38110.AddCondition(UnityEditor.Animations.AnimatorConditionMode.Equals, 0f, "L" + rLayerIndex + "MotionForm");

#if USE_ARCHERY_MP || OOTII_AYMP
            ArcheryPackDefinition.ExtendBasicWalkRunPivot(rMotionController, rLayerIndex);
#endif

#if USE_SWORD_SHIELD_MP || OOTII_SSMP
            SwordShieldPackDefinition.ExtendBasicWalkRunPivot(rMotionController, rLayerIndex);
#endif

#if USE_SPELL_CASTING_MP || OOTII_SCMP
            SpellCastingPackDefinition.ExtendBasicWalkRunPivot(rMotionController, rLayerIndex);
#endif

#if USE_SHOOTER_MP || OOTII_SHMP
            ShooterPackDefinition.ExtendBasicWalkRunPivot(rMotionController, rLayerIndex);
#endif

            // Run any post processing after creating the state machine
            OnStateMachineCreated();
        }
Пример #2
0
        /// <summary>
        /// New way to create sub-state machines without destroying what exists first.
        /// </summary>
        protected override void CreateStateMachine()
        {
            int rLayerIndex = mMotionLayer._AnimatorLayerIndex;
            MotionController rMotionController = mMotionController;

            UnityEditor.Animations.AnimatorController lController = null;

            Animator lAnimator = rMotionController.Animator;

            if (lAnimator == null)
            {
                lAnimator = rMotionController.gameObject.GetComponent <Animator>();
            }
            if (lAnimator != null)
            {
                lController = lAnimator.runtimeAnimatorController as UnityEditor.Animations.AnimatorController;
            }
            if (lController == null)
            {
                return;
            }

            while (lController.layers.Length <= rLayerIndex)
            {
                UnityEditor.Animations.AnimatorControllerLayer lNewLayer = new UnityEditor.Animations.AnimatorControllerLayer();
                lNewLayer.name         = "Layer " + (lController.layers.Length + 1);
                lNewLayer.stateMachine = new UnityEditor.Animations.AnimatorStateMachine();
                lController.AddLayer(lNewLayer);
            }

            UnityEditor.Animations.AnimatorControllerLayer lLayer = lController.layers[rLayerIndex];

            UnityEditor.Animations.AnimatorStateMachine lLayerStateMachine = lLayer.stateMachine;

            UnityEditor.Animations.AnimatorStateMachine lSSM_37926 = MotionControllerMotion.EditorFindSSM(lLayerStateMachine, "BasicWalkRunStrafe-SM");
            if (lSSM_37926 == null)
            {
                lSSM_37926 = lLayerStateMachine.AddStateMachine("BasicWalkRunStrafe-SM", new Vector3(408, -1008, 0));
            }

            UnityEditor.Animations.AnimatorState lState_38402 = MotionControllerMotion.EditorFindState(lSSM_37926, "Unarmed BlendTree");
            if (lState_38402 == null)
            {
                lState_38402 = lSSM_37926.AddState("Unarmed BlendTree", new Vector3(336, 24, 0));
            }
            lState_38402.speed  = 1f;
            lState_38402.mirror = false;
            lState_38402.tag    = "";

            UnityEditor.Animations.BlendTree lM_25600 = MotionControllerMotion.EditorCreateBlendTree("Move Blend Tree", lController, rLayerIndex);
            lM_25600.blendType       = UnityEditor.Animations.BlendTreeType.Simple1D;
            lM_25600.blendParameter  = "InputMagnitude";
            lM_25600.blendParameterY = "InputX";
#if !(UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 || UNITY_5_0 || UNITY_5_1 || UNITY_5_2 || UNITY_5_3)
            lM_25600.useAutomaticThresholds = false;
#endif
            lM_25600.AddChild(MotionControllerMotion.EditorFindAnimationClip("Assets/ootii/MotionController/Content/Animations/Humanoid/Idling/unity_Idle_IdleToIdlesR.fbx", "IdlePose"), 0f);

            UnityEditor.Animations.BlendTree lM_25694 = MotionControllerMotion.EditorCreateBlendTree("WalkTree", lController, rLayerIndex);
            lM_25694.blendType       = UnityEditor.Animations.BlendTreeType.SimpleDirectional2D;
            lM_25694.blendParameter  = "InputX";
            lM_25694.blendParameterY = "InputY";
#if !(UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 || UNITY_5_0 || UNITY_5_1 || UNITY_5_2 || UNITY_5_3)
            lM_25694.useAutomaticThresholds = true;
#endif
            lM_25694.AddChild(MotionControllerMotion.EditorFindAnimationClip("Assets/ootii/MotionController/Content/Animations/Humanoid/Walking/unity_WalkFWD_v2.fbx", "WalkForward"), new Vector2(0f, 0.35f));
            UnityEditor.Animations.ChildMotion[] lM_25694_0_Children = lM_25694.children;
            lM_25694_0_Children[lM_25694_0_Children.Length - 1].mirror    = false;
            lM_25694_0_Children[lM_25694_0_Children.Length - 1].timeScale = 1.1f;
            lM_25694.children = lM_25694_0_Children;

            lM_25694.AddChild(MotionControllerMotion.EditorFindAnimationClip("Assets/ootii/MotionController/Content/Animations/Humanoid/Walking/unity_SWalk_v2.fbx", "SWalkForwardRight"), new Vector2(0.35f, 0.35f));
            UnityEditor.Animations.ChildMotion[] lM_25694_1_Children = lM_25694.children;
            lM_25694_1_Children[lM_25694_1_Children.Length - 1].mirror    = false;
            lM_25694_1_Children[lM_25694_1_Children.Length - 1].timeScale = 1.2f;
            lM_25694.children = lM_25694_1_Children;

            lM_25694.AddChild(MotionControllerMotion.EditorFindAnimationClip("Assets/ootii/MotionController/Content/Animations/Humanoid/Walking/unity_SWalk_v2.fbx", "SWalkForwardLeft"), new Vector2(-0.35f, 0.35f));
            UnityEditor.Animations.ChildMotion[] lM_25694_2_Children = lM_25694.children;
            lM_25694_2_Children[lM_25694_2_Children.Length - 1].mirror    = false;
            lM_25694_2_Children[lM_25694_2_Children.Length - 1].timeScale = 1.2f;
            lM_25694.children = lM_25694_2_Children;

            lM_25694.AddChild(MotionControllerMotion.EditorFindAnimationClip("Assets/ootii/MotionController/Content/Animations/Humanoid/Walking/unity_SWalk_v2.fbx", "SWalkLeft"), new Vector2(-0.35f, 0f));
            UnityEditor.Animations.ChildMotion[] lM_25694_3_Children = lM_25694.children;
            lM_25694_3_Children[lM_25694_3_Children.Length - 1].mirror    = false;
            lM_25694_3_Children[lM_25694_3_Children.Length - 1].timeScale = 1.2f;
            lM_25694.children = lM_25694_3_Children;

            lM_25694.AddChild(MotionControllerMotion.EditorFindAnimationClip("Assets/ootii/MotionController/Content/Animations/Humanoid/Walking/unity_SWalk_v2.fbx", "SWalkRight"), new Vector2(0.35f, 0f));
            UnityEditor.Animations.ChildMotion[] lM_25694_4_Children = lM_25694.children;
            lM_25694_4_Children[lM_25694_4_Children.Length - 1].mirror    = false;
            lM_25694_4_Children[lM_25694_4_Children.Length - 1].timeScale = 1.2f;
            lM_25694.children = lM_25694_4_Children;

            lM_25694.AddChild(MotionControllerMotion.EditorFindAnimationClip("Assets/ootii/MotionController/Content/Animations/Humanoid/Walking/unity_Idle2Strafe_AllAngles.fbx", "WalkStrafeBackwardsLeft"), new Vector2(-0.35f, -0.35f));
            UnityEditor.Animations.ChildMotion[] lM_25694_5_Children = lM_25694.children;
            lM_25694_5_Children[lM_25694_5_Children.Length - 1].mirror    = false;
            lM_25694_5_Children[lM_25694_5_Children.Length - 1].timeScale = 1.1f;
            lM_25694.children = lM_25694_5_Children;

            lM_25694.AddChild(MotionControllerMotion.EditorFindAnimationClip("Assets/ootii/MotionController/Content/Animations/Humanoid/Walking/unity_Idle2Strafe_AllAngles.fbx", "WalkStrafeBackwardsRight"), new Vector2(0.35f, -0.35f));
            UnityEditor.Animations.ChildMotion[] lM_25694_6_Children = lM_25694.children;
            lM_25694_6_Children[lM_25694_6_Children.Length - 1].mirror    = false;
            lM_25694_6_Children[lM_25694_6_Children.Length - 1].timeScale = 1.1f;
            lM_25694.children = lM_25694_6_Children;

            lM_25694.AddChild(MotionControllerMotion.EditorFindAnimationClip("Assets/ootii/MotionController/Content/Animations/Humanoid/Walking/unity_BWalk.fbx", "WalkBackwards"), new Vector2(0f, -0.35f));
            UnityEditor.Animations.ChildMotion[] lM_25694_7_Children = lM_25694.children;
            lM_25694_7_Children[lM_25694_7_Children.Length - 1].mirror    = false;
            lM_25694_7_Children[lM_25694_7_Children.Length - 1].timeScale = 1f;
            lM_25694.children = lM_25694_7_Children;

            lM_25600.AddChild(lM_25694, 0.5f);

            UnityEditor.Animations.BlendTree lM_25630 = MotionControllerMotion.EditorCreateBlendTree("RunTree", lController, rLayerIndex);
            lM_25630.blendType       = UnityEditor.Animations.BlendTreeType.SimpleDirectional2D;
            lM_25630.blendParameter  = "InputX";
            lM_25630.blendParameterY = "InputY";
#if !(UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 || UNITY_5_0 || UNITY_5_1 || UNITY_5_2 || UNITY_5_3)
            lM_25630.useAutomaticThresholds = true;
#endif
            lM_25630.AddChild(MotionControllerMotion.EditorFindAnimationClip("Assets/ootii/MotionController/Content/Animations/Humanoid/Running/RunForward_v2.fbx", "RunForward"), new Vector2(0f, 0.7f));
            UnityEditor.Animations.ChildMotion[] lM_25630_0_Children = lM_25630.children;
            lM_25630_0_Children[lM_25630_0_Children.Length - 1].mirror    = false;
            lM_25630_0_Children[lM_25630_0_Children.Length - 1].timeScale = 1f;
            lM_25630.children = lM_25630_0_Children;

            lM_25630.AddChild(MotionControllerMotion.EditorFindAnimationClip("Assets/ootii/MotionController/Content/Animations/Humanoid/Running/RunStrafe.fbx", "RunStrafeForwardRight"), new Vector2(0.7f, 0.7f));
            UnityEditor.Animations.ChildMotion[] lM_25630_1_Children = lM_25630.children;
            lM_25630_1_Children[lM_25630_1_Children.Length - 1].mirror    = false;
            lM_25630_1_Children[lM_25630_1_Children.Length - 1].timeScale = 1.1f;
            lM_25630.children = lM_25630_1_Children;

            lM_25630.AddChild(MotionControllerMotion.EditorFindAnimationClip("Assets/ootii/MotionController/Content/Animations/Humanoid/Running/RunStrafe.fbx", "RunStrafeForwardLeft"), new Vector2(-0.7f, 0.7f));
            UnityEditor.Animations.ChildMotion[] lM_25630_2_Children = lM_25630.children;
            lM_25630_2_Children[lM_25630_2_Children.Length - 1].mirror    = false;
            lM_25630_2_Children[lM_25630_2_Children.Length - 1].timeScale = 1.1f;
            lM_25630.children = lM_25630_2_Children;

            lM_25630.AddChild(MotionControllerMotion.EditorFindAnimationClip("Assets/ootii/MotionController/Content/Animations/Humanoid/Running/RunStrafe.fbx", "RunStrafeLeft"), new Vector2(-0.7f, 0f));
            UnityEditor.Animations.ChildMotion[] lM_25630_3_Children = lM_25630.children;
            lM_25630_3_Children[lM_25630_3_Children.Length - 1].mirror    = false;
            lM_25630_3_Children[lM_25630_3_Children.Length - 1].timeScale = 1f;
            lM_25630.children = lM_25630_3_Children;

            lM_25630.AddChild(MotionControllerMotion.EditorFindAnimationClip("Assets/ootii/MotionController/Content/Animations/Humanoid/Running/RunStrafe.fbx", "RunStrafeRight"), new Vector2(0.7f, 0f));
            UnityEditor.Animations.ChildMotion[] lM_25630_4_Children = lM_25630.children;
            lM_25630_4_Children[lM_25630_4_Children.Length - 1].mirror    = false;
            lM_25630_4_Children[lM_25630_4_Children.Length - 1].timeScale = 1f;
            lM_25630.children = lM_25630_4_Children;

            lM_25630.AddChild(MotionControllerMotion.EditorFindAnimationClip("Assets/ootii/MotionController/Content/Animations/Humanoid/Running/RunStrafe.fbx", "RunStrafeBackwardLeft"), new Vector2(-0.7f, -0.7f));
            UnityEditor.Animations.ChildMotion[] lM_25630_5_Children = lM_25630.children;
            lM_25630_5_Children[lM_25630_5_Children.Length - 1].mirror    = false;
            lM_25630_5_Children[lM_25630_5_Children.Length - 1].timeScale = 1.1f;
            lM_25630.children = lM_25630_5_Children;

            lM_25630.AddChild(MotionControllerMotion.EditorFindAnimationClip("Assets/ootii/MotionController/Content/Animations/Humanoid/Running/RunStrafe.fbx", "RunStrafeBackwardRight"), new Vector2(0.7f, -0.7f));
            UnityEditor.Animations.ChildMotion[] lM_25630_6_Children = lM_25630.children;
            lM_25630_6_Children[lM_25630_6_Children.Length - 1].mirror    = false;
            lM_25630_6_Children[lM_25630_6_Children.Length - 1].timeScale = 1.1f;
            lM_25630.children = lM_25630_6_Children;

            lM_25630.AddChild(MotionControllerMotion.EditorFindAnimationClip("Assets/ootii/MotionController/Content/Animations/Humanoid/Running/RunBackward.fbx", "RunBackwards"), new Vector2(0f, -0.7f));
            UnityEditor.Animations.ChildMotion[] lM_25630_7_Children = lM_25630.children;
            lM_25630_7_Children[lM_25630_7_Children.Length - 1].mirror    = false;
            lM_25630_7_Children[lM_25630_7_Children.Length - 1].timeScale = 1f;
            lM_25630.children = lM_25630_7_Children;

            lM_25600.AddChild(lM_25630, 1f);
            lState_38402.motion = lM_25600;

            UnityEditor.Animations.AnimatorStateTransition lAnyTransition_38112 = MotionControllerMotion.EditorFindAnyStateTransition(lLayerStateMachine, lState_38402, 0);
            if (lAnyTransition_38112 == null)
            {
                lAnyTransition_38112 = lLayerStateMachine.AddAnyStateTransition(lState_38402);
            }
            lAnyTransition_38112.isExit              = false;
            lAnyTransition_38112.hasExitTime         = false;
            lAnyTransition_38112.hasFixedDuration    = true;
            lAnyTransition_38112.exitTime            = 0.9f;
            lAnyTransition_38112.duration            = 0.2f;
            lAnyTransition_38112.offset              = 0f;
            lAnyTransition_38112.mute                = false;
            lAnyTransition_38112.solo                = false;
            lAnyTransition_38112.canTransitionToSelf = true;
            lAnyTransition_38112.interruptionSource  = (UnityEditor.Animations.TransitionInterruptionSource) 0;
            for (int i = lAnyTransition_38112.conditions.Length - 1; i >= 0; i--)
            {
                lAnyTransition_38112.RemoveCondition(lAnyTransition_38112.conditions[i]);
            }
            lAnyTransition_38112.AddCondition(UnityEditor.Animations.AnimatorConditionMode.Equals, 3100f, "L" + rLayerIndex + "MotionPhase");
            lAnyTransition_38112.AddCondition(UnityEditor.Animations.AnimatorConditionMode.Equals, 0f, "L" + rLayerIndex + "MotionForm");

#if USE_ARCHERY_MP || OOTII_AYMP
            ArcheryPackDefinition.ExtendBasicWalkRunStrafe(rMotionController, rLayerIndex);
#endif

#if USE_SWORD_SHIELD_MP || OOTII_SSMP
            SwordShieldPackDefinition.ExtendBasicWalkRunStrafe(rMotionController, rLayerIndex);
#endif

#if USE_SPELL_CASTING_MP || OOTII_SCMP
            SpellCastingPackDefinition.ExtendBasicWalkRunStrafe(rMotionController, rLayerIndex);
#endif

#if USE_SHOOTER_MP || OOTII_SHMP
            ShooterPackDefinition.ExtendBasicWalkRunStrafe(rMotionController, rLayerIndex);
#endif

            // Run any post processing after creating the state machine
            OnStateMachineCreated();
        }