Exemple #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_37922 = MotionControllerMotion.EditorFindSSM(lLayerStateMachine, "BasicIdle-SM");
            if (lSSM_37922 == null)
            {
                lSSM_37922 = lLayerStateMachine.AddStateMachine("BasicIdle-SM", new Vector3(192, -1056, 0));
            }

            UnityEditor.Animations.AnimatorState lState_38398 = MotionControllerMotion.EditorFindState(lSSM_37922, "Unarmed Idle Pose");
            if (lState_38398 == null)
            {
                lState_38398 = lSSM_37922.AddState("Unarmed Idle Pose", new Vector3(312, 84, 0));
            }
            lState_38398.speed  = 1f;
            lState_38398.mirror = false;
            lState_38398.tag    = "";
            lState_38398.motion = MotionControllerMotion.EditorFindAnimationClip("Assets/ootii/Assets/MotionController/Content/Animations/Humanoid/Idling/unity_Idle_IdleToIdlesR.fbx", "IdlePose");

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

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

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

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

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

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

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