Example #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();
        }