예제 #1
0
파일: Idle.cs 프로젝트: cspid/TheOutside
        /// <summary>
        /// Creates the animator substate machine for this motion.
        /// </summary>
        protected override void CreateStateMachine()
        {
            // Grab the root sm for the layer
            UnityEditor.Animations.AnimatorStateMachine lRootStateMachine = _EditorAnimatorController.layers[mMotionLayer.AnimatorLayerIndex].stateMachine;

            // If we find the sm with our name, remove it
            for (int i = 0; i < lRootStateMachine.stateMachines.Length; i++)
            {
                // Look for a sm with the matching name
                if (lRootStateMachine.stateMachines[i].stateMachine.name == _EditorAnimatorSMName)
                {
                    // Allow the user to stop before we remove the sm
                    if (!UnityEditor.EditorUtility.DisplayDialog("Motion Controller", _EditorAnimatorSMName + " already exists. Delete and recreate it?", "Yes", "No"))
                    {
                        return;
                    }

                    // Remove the sm
                    lRootStateMachine.RemoveStateMachine(lRootStateMachine.stateMachines[i].stateMachine);
                }
            }

            UnityEditor.Animations.AnimatorStateMachine lMotionStateMachine = lRootStateMachine.AddStateMachine(_EditorAnimatorSMName);

            // Attach the behaviour if needed
            if (_EditorAttachBehaviour)
            {
                MotionControllerBehaviour lBehaviour = lMotionStateMachine.AddStateMachineBehaviour(typeof(MotionControllerBehaviour)) as MotionControllerBehaviour;
                lBehaviour._MotionKey = (_Key.Length > 0 ? _Key : this.GetType().FullName);
            }

            UnityEditor.Animations.AnimatorState lIdlePose = lMotionStateMachine.AddState("IdlePose", new Vector3(264, 72, 0));
            lIdlePose.motion = mIdlePose;
            lIdlePose.speed  = 1f;

            UnityEditor.Animations.AnimatorStateTransition lAnyStateTransition = null;

            // Create the transition from the any state. Note that 'AnyState' transitions have to be added to the root
            lAnyStateTransition                  = lRootStateMachine.AddAnyStateTransition(lIdlePose);
            lAnyStateTransition.hasExitTime      = false;
            lAnyStateTransition.hasFixedDuration = true;
            lAnyStateTransition.exitTime         = 0.8144876f;
            lAnyStateTransition.duration         = 0.01185336f;
            lAnyStateTransition.offset           = 0f;
            lAnyStateTransition.mute             = false;
            lAnyStateTransition.solo             = false;
            lAnyStateTransition.AddCondition(UnityEditor.Animations.AnimatorConditionMode.Equals, 100f, "L0MotionPhase");
        }
            bool ContainsStateEditor(AlmenaraGames.MLPASAnimatorSFX state, out ValuesOverride valuesOverride)
            {
                UnityEditor.Animations.StateMachineBehaviourContext[] context = UnityEditor.Animations.AnimatorController.FindStateMachineBehaviourContext(state);
                UnityEditor.Animations.AnimatorState        cState            = (context[0].animatorObject as UnityEditor.Animations.AnimatorState);
                UnityEditor.Animations.AnimatorStateMachine cStateMachine     = (context[0].animatorObject as UnityEditor.Animations.AnimatorStateMachine);

                string stateName = cState != null ? cState.name : cStateMachine.name;
                int    layer     = context[0].layerIndex;

                if ((obj.targetObject as MLPASAnimatorSFXController).newValues.Exists(x => x.stateName == stateName && x.layer == layer))
                {
                    valuesOverride = (obj.targetObject as MLPASAnimatorSFXController).newValues.Find(x => x.stateName == stateName && x.layer == layer);
                    return(true);
                }

                valuesOverride = null;
                return(false);
            }
예제 #3
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_N2456644 = MotionControllerMotion.EditorFindSSM(lLayerStateMachine, "BasicIdleArms-SM");
            if (lSSM_N2456644 == null)
            {
                lSSM_N2456644 = lLayerStateMachine.AddStateMachine("BasicIdleArms-SM", new Vector3(192, -816, 0));
            }

            // Run any post processing after creating the state machine
            OnStateMachineCreated();
        }
예제 #4
0
        void addRNStateMachine(UnityEditor.Animations.AnimatorStateMachine stateMachine)
        {
            foreach (var state in stateMachine.states)
            {
                var has = false;
                foreach (var behaviour in state.state.behaviours)
                {
                    if (behaviour is StateMachine)
                    {
                        has = true;
                        break;
                    }
                }


                //
                if (has == false)
                {
                    state.state.AddStateMachineBehaviour <StateMachine>();
                }
            }
        }
예제 #5
0
        public static UnityEditor.Animations.AnimatorController BuildAnimatorController(List <AnimationClip> clips, string path)
        {
            CheckPath(path);


            UnityEditor.Animations.AnimatorController      animatorController = UnityEditor.Animations.AnimatorController.CreateAnimatorControllerAtPath(path);
            UnityEditor.Animations.AnimatorControllerLayer layer = animatorController.layers[0];
            UnityEditor.Animations.AnimatorStateMachine    sm    = layer.stateMachine;

            foreach (AnimationClip clip in clips)
            {
                UnityEditor.Animations.AnimatorState state = sm.AddState(clip.name);
                state.motion = clip;

                if (clip.name.IndexOf("idle") != -1)
                {
                    sm.defaultState = state;
                }
            }
            AssetDatabase.SaveAssets();
            return(animatorController);
        }
예제 #6
0
        /// <summary>
        /// Gets the name of the animation state.
        /// </summary>
        /// <returns>The animation state name.</returns>
        /// <param name="_animator">Animator.</param>
        /// <param name="_name">Name.</param>
        public static string GetAnimatorStateName(Animator _animator, string _name)
        {
            if (string.IsNullOrEmpty(_name) || _animator == null || _animator.runtimeAnimatorController == null)
            {
                return("");
            }
                        #if UNITY_EDITOR
            UnityEditor.Animations.AnimatorController _controller = _animator.runtimeAnimatorController as UnityEditor.Animations.AnimatorController;

            foreach (UnityEditor.Animations.AnimatorControllerLayer _layer in _controller.layers)
            {
                UnityEditor.Animations.AnimatorStateMachine _state_machine = _layer.stateMachine;

                foreach (UnityEditor.Animations.ChildAnimatorState _state in _state_machine.states)
                {
                    if (_state.state != null && _state.state.motion != null && _state.state.motion.name == _name)
                    {
                        return(_state.state.name);
                    }
                }
            }
                        #endif
            return("");
        }
예제 #7
0
        public AnimationControlParamter GetAnimationParamter(string animationName)
        {
            AnimationControlParamter paramter = new AnimationControlParamter();

            AnimationClip[] clips = animator.runtimeAnimatorController.animationClips;
            for (int i = 0; i < clips.Length; i++)
            {
                if (clips[i].name == animationName)
                {
                    if (clips[i].wrapMode == WrapMode.Loop)
                    {
                        paramter.bLoop = true;
                    }
                    else
                    {
                        paramter.bLoop = false;
                    }
                    break;
                }
            }
#if UNITY_EDITOR
            UnityEditor.Animations.AnimatorController ac = animator.runtimeAnimatorController as UnityEditor.Animations.AnimatorController;
            //获取状态机
            UnityEditor.Animations.AnimatorStateMachine asm = ac.layers[0].stateMachine;
            for (int i = 0; i < asm.states.Length; i++)
            {
                UnityEditor.Animations.ChildAnimatorState cs = asm.states[i];
                if (cs.state.name == animationName)
                {
                    paramter.timeScale = cs.state.speed;
                    break;
                }
            }
#endif
            return(paramter);
        }
예제 #8
0
        public AnimatorStateMachine(AnimatorControllerLayer l, AnimatorStateMachine parentStateMachine, UnityEditor.Animations.AnimatorStateMachine sm)
        {
            this.layer = l;
            this.parentStateMachine = parentStateMachine;
            this.asset = sm;

            this.name     = sm.name;
            this.fullPath = parentStateMachine == null ? sm.name : parentStateMachine.fullPath + "." + sm.name;
            this.id       = UnityEngine.Animator.StringToHash(fullPath);
            l.stateMachines.Add(this);

            //this.nameHash = Animator.StringToHash(sm.name);
            this.defaultState = sm.defaultState == null ? 0 : l.stateMap[sm.defaultState];
            foreach (var s in sm.states)
            {
                states.Add(new AnimatorState(this, s.state).id);
            }
            foreach (var s in sm.stateMachines)
            {
                stateMachines.Add(new AnimatorStateMachine(l, this, s.stateMachine).id);
            }
            foreach (var t in sm.anyStateTransitions)
            {
                anyStateTransitions.Add(new AnimatorStateTransition(this, null, t));
            }
            foreach (var t in sm.entryTransitions)
            {
                entryTransitions.Add(new AnimatorStateTransition(this, null, t));
            }
        }
예제 #9
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();
        }
예제 #10
0
        /// <summary>
        /// Creates the animator substate machine for this motion.
        /// </summary>
        protected override void CreateStateMachine()
        {
            // Grab the root sm for the layer
            UnityEditor.Animations.AnimatorStateMachine lRootStateMachine    = _EditorAnimatorController.layers[mMotionLayer.AnimatorLayerIndex].stateMachine;
            UnityEditor.Animations.AnimatorStateMachine lSM_21500            = _EditorAnimatorController.layers[mMotionLayer.AnimatorLayerIndex].stateMachine;
            UnityEditor.Animations.AnimatorStateMachine lRootSubStateMachine = null;

            // If we find the sm with our name, remove it
            for (int i = 0; i < lRootStateMachine.stateMachines.Length; i++)
            {
                // Look for a sm with the matching name
                if (lRootStateMachine.stateMachines[i].stateMachine.name == _EditorAnimatorSMName)
                {
                    lRootSubStateMachine = lRootStateMachine.stateMachines[i].stateMachine;

                    // Allow the user to stop before we remove the sm
                    if (!UnityEditor.EditorUtility.DisplayDialog("Motion Controller", _EditorAnimatorSMName + " already exists. Delete and recreate it?", "Yes", "No"))
                    {
                        return;
                    }

                    // Remove the sm
                    //lRootStateMachine.RemoveStateMachine(lRootStateMachine.stateMachines[i].stateMachine);
                    break;
                }
            }

            UnityEditor.Animations.AnimatorStateMachine lSM_21546 = lRootSubStateMachine;
            if (lSM_21546 != null)
            {
                for (int i = lSM_21546.entryTransitions.Length - 1; i >= 0; i--)
                {
                    lSM_21546.RemoveEntryTransition(lSM_21546.entryTransitions[i]);
                }

                for (int i = lSM_21546.anyStateTransitions.Length - 1; i >= 0; i--)
                {
                    lSM_21546.RemoveAnyStateTransition(lSM_21546.anyStateTransitions[i]);
                }

                for (int i = lSM_21546.states.Length - 1; i >= 0; i--)
                {
                    lSM_21546.RemoveState(lSM_21546.states[i].state);
                }

                for (int i = lSM_21546.stateMachines.Length - 1; i >= 0; i--)
                {
                    lSM_21546.RemoveStateMachine(lSM_21546.stateMachines[i].stateMachine);
                }
            }
            else
            {
                lSM_21546 = lSM_21500.AddStateMachine(_EditorAnimatorSMName, new Vector3(192, -696, 0));
            }

            UnityEditor.Animations.AnimatorState lS_22652 = lSM_21546.AddState("IdlePose", new Vector3(504, 72, 0));
            lS_22652.speed  = 1f;
            lS_22652.motion = m14306;

            UnityEditor.Animations.AnimatorState lS_21796 = lSM_21546.AddState("Move Tree", new Vector3(264, 72, 0));
            lS_21796.speed = 1f;

            UnityEditor.Animations.BlendTree lM_15642 = CreateBlendTree("Blend Tree", _EditorAnimatorController, mMotionLayer.AnimatorLayerIndex);
            lM_15642.blendType       = UnityEditor.Animations.BlendTreeType.FreeformCartesian2D;
            lM_15642.blendParameter  = "InputX";
            lM_15642.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_15642.useAutomaticThresholds = true;
#endif
            lM_15642.AddChild(m14708, new Vector2(0f, 0.7f));
            UnityEditor.Animations.ChildMotion[] lM_15642_0_Children = lM_15642.children;
            lM_15642_0_Children[lM_15642_0_Children.Length - 1].mirror    = false;
            lM_15642_0_Children[lM_15642_0_Children.Length - 1].timeScale = 1.2f;
            lM_15642.children = lM_15642_0_Children;

            lM_15642.AddChild(m14710, new Vector2(-0.7f, 0.7f));
            UnityEditor.Animations.ChildMotion[] lM_15642_1_Children = lM_15642.children;
            lM_15642_1_Children[lM_15642_1_Children.Length - 1].mirror    = false;
            lM_15642_1_Children[lM_15642_1_Children.Length - 1].timeScale = 1.1f;
            lM_15642.children = lM_15642_1_Children;

            lM_15642.AddChild(m14712, new Vector2(0.7f, 0.7f));
            UnityEditor.Animations.ChildMotion[] lM_15642_2_Children = lM_15642.children;
            lM_15642_2_Children[lM_15642_2_Children.Length - 1].mirror    = false;
            lM_15642_2_Children[lM_15642_2_Children.Length - 1].timeScale = 1.1f;
            lM_15642.children = lM_15642_2_Children;

            lM_15642.AddChild(m14716, new Vector2(-0.7f, 0f));
            UnityEditor.Animations.ChildMotion[] lM_15642_3_Children = lM_15642.children;
            lM_15642_3_Children[lM_15642_3_Children.Length - 1].mirror    = false;
            lM_15642_3_Children[lM_15642_3_Children.Length - 1].timeScale = 1.1f;
            lM_15642.children = lM_15642_3_Children;

            lM_15642.AddChild(m14714, new Vector2(0f, 0f));
            UnityEditor.Animations.ChildMotion[] lM_15642_4_Children = lM_15642.children;
            lM_15642_4_Children[lM_15642_4_Children.Length - 1].mirror    = false;
            lM_15642_4_Children[lM_15642_4_Children.Length - 1].timeScale = 1.3f;
            lM_15642.children = lM_15642_4_Children;

            lM_15642.AddChild(m14718, new Vector2(0.7f, 0f));
            UnityEditor.Animations.ChildMotion[] lM_15642_5_Children = lM_15642.children;
            lM_15642_5_Children[lM_15642_5_Children.Length - 1].mirror    = false;
            lM_15642_5_Children[lM_15642_5_Children.Length - 1].timeScale = 1.5f;
            lM_15642.children = lM_15642_5_Children;

            lM_15642.AddChild(m14704, new Vector2(-0.7f, -0.7f));
            UnityEditor.Animations.ChildMotion[] lM_15642_6_Children = lM_15642.children;
            lM_15642_6_Children[lM_15642_6_Children.Length - 1].mirror    = false;
            lM_15642_6_Children[lM_15642_6_Children.Length - 1].timeScale = 1.5f;
            lM_15642.children = lM_15642_6_Children;

            lM_15642.AddChild(m14706, new Vector2(0.7f, -0.7f));
            UnityEditor.Animations.ChildMotion[] lM_15642_7_Children = lM_15642.children;
            lM_15642_7_Children[lM_15642_7_Children.Length - 1].mirror    = false;
            lM_15642_7_Children[lM_15642_7_Children.Length - 1].timeScale = 1.5f;
            lM_15642.children = lM_15642_7_Children;

            lM_15642.AddChild(m14702, new Vector2(0f, -0.7f));
            UnityEditor.Animations.ChildMotion[] lM_15642_8_Children = lM_15642.children;
            lM_15642_8_Children[lM_15642_8_Children.Length - 1].mirror    = false;
            lM_15642_8_Children[lM_15642_8_Children.Length - 1].timeScale = 1.5f;
            lM_15642.children = lM_15642_8_Children;

            lS_21796.motion = lM_15642;

            // Create the transition from the any state. Note that 'AnyState' transitions have to be added to the root
            UnityEditor.Animations.AnimatorStateTransition lT_21654 = lRootStateMachine.AddAnyStateTransition(lS_21796);
            lT_21654.hasExitTime         = false;
            lT_21654.hasFixedDuration    = true;
            lT_21654.exitTime            = 0.9f;
            lT_21654.duration            = 0.2f;
            lT_21654.offset              = 0f;
            lT_21654.mute                = false;
            lT_21654.solo                = false;
            lT_21654.canTransitionToSelf = true;
            lT_21654.interruptionSource  = (UnityEditor.Animations.TransitionInterruptionSource) 0;
            lT_21654.AddCondition(UnityEditor.Animations.AnimatorConditionMode.Equals, 620f, "L0MotionPhase");

            UnityEditor.Animations.AnimatorStateTransition lT_22654 = lS_21796.AddTransition(lS_22652);
            lT_22654.hasExitTime         = false;
            lT_22654.hasFixedDuration    = true;
            lT_22654.exitTime            = 0.9f;
            lT_22654.duration            = 0.2f;
            lT_22654.offset              = 0f;
            lT_22654.mute                = false;
            lT_22654.solo                = false;
            lT_22654.canTransitionToSelf = true;
            lT_22654.interruptionSource  = (UnityEditor.Animations.TransitionInterruptionSource) 0;
            lT_22654.AddCondition(UnityEditor.Animations.AnimatorConditionMode.Equals, 610f, "L0MotionPhase");
        }
예제 #11
0
        public static UnityEditor.Animations.AnimatorController BuildAnimationController(List <AnimationClip> clips, string path)
        {
            CheckPath(path, true);
            UnityEditor.Animations.AnimatorController      animatorController = UnityEditor.Animations.AnimatorController.CreateAnimatorControllerAtPath(path);
            UnityEditor.Animations.AnimatorControllerLayer layer = animatorController.layers[0];
            UnityEditor.Animations.AnimatorStateMachine    sm    = layer.stateMachine;

            animatorController.AddParameter("stage", AnimatorControllerParameterType.Int);
            animatorController.AddParameter("angle", AnimatorControllerParameterType.Int);

            string[] stateNames             = new string[] { "idle", "run", "attack", "skill1", "hurt", "die" };
            Dictionary <string, int> states = new Dictionary <string, int>();

            for (int i = 0; i < stateNames.Length; i++)
            {
                states.Add(stateNames[i], i);
                states.Add("front_" + stateNames[i], i);
                states.Add("back_" + stateNames[i], i);
                states.Add("0_" + stateNames[i], i);
                states.Add("45_" + stateNames[i], i);
                states.Add("90_" + stateNames[i], i);
                states.Add("135_" + stateNames[i], i);
                states.Add("180_" + stateNames[i], i);
                states.Add("225_" + stateNames[i], i);
                states.Add("270_" + stateNames[i], i);
            }

            foreach (AnimationClip newClip in clips)
            {
                UnityEditor.Animations.AnimatorState state = sm.AddState(newClip.name);
                //			state.SetAnimationClip(newClip,layer);
                state.motion = newClip;
//				UnityEditor.Animations.AnimatorTransition trans = sm.AddEntryTransition(state);

//				if(states.ContainsKey(newClip.name))
//				{
//					trans.AddCondition(UnityEditor.Animations.AnimatorConditionMode.Equals, states[newClip.name], "stage");
//				}
//
//				if(newClip.name.IndexOf("front_") != -1)
//				{
//					trans.AddCondition(UnityEditor.Animations.AnimatorConditionMode.Greater, 89, "angle");
//				}
//
//				if(newClip.name.IndexOf("back_") != -1)
//				{
//					trans.AddCondition(UnityEditor.Animations.AnimatorConditionMode.Less, 90, "angle");
//				}
//
//				//
//				UnityEditor.Animations.AnimatorStateTransition animatorStateTransition = state.AddExitTransition(true);
//				animatorStateTransition.exitTime = 0f;
//				animatorStateTransition.duration = 0f;

                if (newClip.name.IndexOf("idle") != -1)
                {
                    sm.defaultState = state;
                }
            }
            AssetDatabase.SaveAssets();
            return(animatorController);
        }
예제 #12
0
        /// <summary>
        /// Initialise this animation bridge.
        /// </summary>
        protected void Init()
        {
            // Get character reference
            myCharacter = (IMob)gameObject.GetComponent(typeof(IMob));
            if (myCharacter == null)
            {
                myCharacter = (IMob)gameObject.GetComponentInParent(typeof(IMob));
            }
            if (myCharacter == null)
            {
                Debug.LogError("Mecanim Animation Bridge (2D) unable to find Character or Enemy reference");
            }
            myCharacter.ChangeAnimationState += AnimationStateChanged;
            myAnimator = GetComponentInChildren <Animator>();
            if (myAnimator == null)
            {
                Debug.LogError("Platform Animator unable to find Unity Animator reference");
            }
            defaultController = myAnimator.runtimeAnimatorController;


            animationStateOverrideLookup = new Dictionary <string, AnimatorOverrideController> ();
            foreach (AnimatorControllerMapping mapping in mappings)
            {
                animationStateOverrideLookup.Add(mapping.overrrideState, mapping.controller);
            }

            queuedStates     = new Queue <AnimationState> ();
            queuedPriorities = new Queue <int> ();
            state            = AnimationState.NONE;
            priority         = -1;

            TimeManager.Instance.GamePaused   += HandleGamePaused;
            TimeManager.Instance.GameUnPaused += HandleGameUnPaused;

#if UNITY_EDITOR
        #if UNITY_5
            // In editor mode build a list of handled states for error messaging and the like
            if (myAnimator.runtimeAnimatorController is UnityEditor.Animations.AnimatorController)
            {
                editor_stateNames = new List <string>();
                UnityEditor.Animations.AnimatorStateMachine stateMachine = ((UnityEditor.Animations.AnimatorController)defaultController).layers[0].stateMachine;
                for (int i = 0; i < stateMachine.states.Length; i++)
                {
                    editor_stateNames.Add(stateMachine.states[i].state.name);
                }
            }
        #else
            // In editor mode build a list of handled states for error messaging and the like
            if (myAnimator.runtimeAnimatorController is UnityEditor.Animations.AnimatorController)
            {
                editor_stateNames = new List <string>();
                UnityEditor.Animations.AnimatorStateMachine stateMachine = ((UnityEditor.Animations.AnimatorController)defaultController).layers[0].stateMachine;
                for (int i = 0; i < stateMachine.states.Length; i++)
                {
                    editor_stateNames.Add(stateMachine.states[i].state.name);
                }
            }
        #endif
#endif
        }
예제 #13
0
        /// <summary>
        /// Creates the animator substate machine for this motion.
        /// </summary>
        protected override void CreateStateMachine()
        {
            // Grab the root sm for the layer
            UnityEditor.Animations.AnimatorStateMachine lRootStateMachine    = _EditorAnimatorController.layers[mMotionLayer.AnimatorLayerIndex].stateMachine;
            UnityEditor.Animations.AnimatorStateMachine lSM_25382            = _EditorAnimatorController.layers[mMotionLayer.AnimatorLayerIndex].stateMachine;
            UnityEditor.Animations.AnimatorStateMachine lRootSubStateMachine = null;

            // If we find the sm with our name, remove it
            for (int i = 0; i < lRootStateMachine.stateMachines.Length; i++)
            {
                // Look for a sm with the matching name
                if (lRootStateMachine.stateMachines[i].stateMachine.name == _EditorAnimatorSMName)
                {
                    lRootSubStateMachine = lRootStateMachine.stateMachines[i].stateMachine;

                    // Allow the user to stop before we remove the sm
                    if (!UnityEditor.EditorUtility.DisplayDialog("Motion Controller", _EditorAnimatorSMName + " already exists. Delete and recreate it?", "Yes", "No"))
                    {
                        return;
                    }

                    // Remove the sm
                    //lRootStateMachine.RemoveStateMachine(lRootStateMachine.stateMachines[i].stateMachine);
                    break;
                }
            }

            UnityEditor.Animations.AnimatorStateMachine lSM_N1608508 = lRootSubStateMachine;
            if (lSM_N1608508 != null)
            {
                for (int i = lSM_N1608508.entryTransitions.Length - 1; i >= 0; i--)
                {
                    lSM_N1608508.RemoveEntryTransition(lSM_N1608508.entryTransitions[i]);
                }

                for (int i = lSM_N1608508.anyStateTransitions.Length - 1; i >= 0; i--)
                {
                    lSM_N1608508.RemoveAnyStateTransition(lSM_N1608508.anyStateTransitions[i]);
                }

                for (int i = lSM_N1608508.states.Length - 1; i >= 0; i--)
                {
                    lSM_N1608508.RemoveState(lSM_N1608508.states[i].state);
                }

                for (int i = lSM_N1608508.stateMachines.Length - 1; i >= 0; i--)
                {
                    lSM_N1608508.RemoveStateMachine(lSM_N1608508.stateMachines[i].stateMachine);
                }
            }
            else
            {
                lSM_N1608508 = lSM_25382.AddStateMachine(_EditorAnimatorSMName, new Vector3(192, -564, 0));
            }

            UnityEditor.Animations.AnimatorState lS_N1612918 = lSM_N1608508.AddState("LandToIdle", new Vector3(720, 264, 0));
            lS_N1612918.speed  = 1f;
            lS_N1612918.motion = m16578;

            UnityEditor.Animations.AnimatorState lS_N1612942 = lSM_N1608508.AddState("FallToLand", new Vector3(480, 264, 0));
            lS_N1612942.speed  = 1f;
            lS_N1612942.motion = m16574;

            UnityEditor.Animations.AnimatorState lS_N1626950 = lSM_N1608508.AddState("FallPose", new Vector3(240, 264, 0));
            lS_N1626950.speed  = 1f;
            lS_N1626950.motion = m16572;

            UnityEditor.Animations.AnimatorState lS_N1644298 = lSM_N1608508.AddState("IdlePose", new Vector3(960, 264, 0));
            lS_N1644298.speed  = 1f;
            lS_N1644298.motion = m14540;

            // Create the transition from the any state. Note that 'AnyState' transitions have to be added to the root
            UnityEditor.Animations.AnimatorStateTransition lT_N1951384 = lRootStateMachine.AddAnyStateTransition(lS_N1626950);
            lT_N1951384.hasExitTime         = false;
            lT_N1951384.hasFixedDuration    = true;
            lT_N1951384.exitTime            = 0.9f;
            lT_N1951384.duration            = 0.2f;
            lT_N1951384.offset              = 0f;
            lT_N1951384.mute                = false;
            lT_N1951384.solo                = false;
            lT_N1951384.canTransitionToSelf = true;
            lT_N1951384.interruptionSource  = (UnityEditor.Animations.TransitionInterruptionSource) 0;
            lT_N1951384.AddCondition(UnityEditor.Animations.AnimatorConditionMode.Equals, 1800f, "L0MotionPhase");

            UnityEditor.Animations.AnimatorStateTransition lT_N1644504 = lS_N1612918.AddTransition(lS_N1644298);
            lT_N1644504.hasExitTime         = true;
            lT_N1644504.hasFixedDuration    = true;
            lT_N1644504.exitTime            = 0.8141199f;
            lT_N1644504.duration            = 0.116312f;
            lT_N1644504.offset              = 0f;
            lT_N1644504.mute                = false;
            lT_N1644504.solo                = false;
            lT_N1644504.canTransitionToSelf = true;
            lT_N1644504.interruptionSource  = (UnityEditor.Animations.TransitionInterruptionSource) 0;

            UnityEditor.Animations.AnimatorStateTransition lT_N1612980 = lS_N1612942.AddTransition(lS_N1612918);
            lT_N1612980.hasExitTime         = true;
            lT_N1612980.hasFixedDuration    = true;
            lT_N1612980.exitTime            = 0.5f;
            lT_N1612980.duration            = 0.2f;
            lT_N1612980.offset              = 0.485189f;
            lT_N1612980.mute                = false;
            lT_N1612980.solo                = false;
            lT_N1612980.canTransitionToSelf = true;
            lT_N1612980.interruptionSource  = (UnityEditor.Animations.TransitionInterruptionSource) 0;

            UnityEditor.Animations.AnimatorStateTransition lT_N1626992 = lS_N1626950.AddTransition(lS_N1612942);
            lT_N1626992.hasExitTime         = false;
            lT_N1626992.hasFixedDuration    = true;
            lT_N1626992.exitTime            = 1f;
            lT_N1626992.duration            = 0.1f;
            lT_N1626992.offset              = 0f;
            lT_N1626992.mute                = false;
            lT_N1626992.solo                = false;
            lT_N1626992.canTransitionToSelf = true;
            lT_N1626992.interruptionSource  = (UnityEditor.Animations.TransitionInterruptionSource) 0;
            lT_N1626992.AddCondition(UnityEditor.Animations.AnimatorConditionMode.Equals, 1805f, "L0MotionPhase");
        }
예제 #14
0
        /// <summary>
        /// Creates the animator substate machine for this motion.
        /// </summary>
        protected override void CreateStateMachine()
        {
            // Grab the root sm for the layer
            UnityEditor.Animations.AnimatorStateMachine lRootStateMachine = _EditorAnimatorController.layers[mMotionLayer.AnimatorLayerIndex].stateMachine;

            // If we find the sm with our name, remove it
            for (int i = 0; i < lRootStateMachine.stateMachines.Length; i++)
            {
                // Look for a sm with the matching name
                if (lRootStateMachine.stateMachines[i].stateMachine.name == _EditorAnimatorSMName)
                {
                    // Allow the user to stop before we remove the sm
                    if (!UnityEditor.EditorUtility.DisplayDialog("Motion Controller", _EditorAnimatorSMName + " already exists. Delete and recreate it?", "Yes", "No"))
                    {
                        return;
                    }

                    // Remove the sm
                    lRootStateMachine.RemoveStateMachine(lRootStateMachine.stateMachines[i].stateMachine);
                }
            }

            UnityEditor.Animations.AnimatorStateMachine lMotionStateMachine = lRootStateMachine.AddStateMachine(_EditorAnimatorSMName);

            // Attach the behaviour if needed
            if (_EditorAttachBehaviour)
            {
                MotionControllerBehaviour lBehaviour = lMotionStateMachine.AddStateMachineBehaviour(typeof(MotionControllerBehaviour)) as MotionControllerBehaviour;
                lBehaviour._MotionKey = (_Key.Length > 0 ? _Key : this.GetType().FullName);
            }

            UnityEditor.Animations.AnimatorState lIdlePose = lMotionStateMachine.AddState("IdlePose", new Vector3(840, 204, 0));
            lIdlePose.motion = mIdlePose;
            lIdlePose.speed  = 1f;

            UnityEditor.Animations.AnimatorState lRunJump_RunForward = lMotionStateMachine.AddState("RunJump_RunForward", new Vector3(588, 288, 0));
            lRunJump_RunForward.motion = mRunForward;
            lRunJump_RunForward.speed  = 1f;

            UnityEditor.Animations.AnimatorState lRunningJump = lMotionStateMachine.AddState("RunningJump", new Vector3(324, 204, 0));
            lRunningJump.motion = mRunningJump;
            lRunningJump.speed  = 1f;

            UnityEditor.Animations.AnimatorState lLandToIdle = lMotionStateMachine.AddState("LandToIdle", new Vector3(588, 204, 0));
            lLandToIdle.motion = mLandToIdle;
            lLandToIdle.speed  = 1f;

            UnityEditor.Animations.AnimatorStateTransition lAnyStateTransition = null;

            // Create the transition from the any state. Note that 'AnyState' transitions have to be added to the root
            lAnyStateTransition                  = lRootStateMachine.AddAnyStateTransition(lRunningJump);
            lAnyStateTransition.hasExitTime      = false;
            lAnyStateTransition.hasFixedDuration = true;
            lAnyStateTransition.exitTime         = 0.9f;
            lAnyStateTransition.duration         = 0.05f;
            lAnyStateTransition.offset           = 0f;
            lAnyStateTransition.mute             = false;
            lAnyStateTransition.solo             = false;
            lAnyStateTransition.AddCondition(UnityEditor.Animations.AnimatorConditionMode.Equals, 27500f, "L0MotionPhase");

            UnityEditor.Animations.AnimatorStateTransition lStateTransition = null;

            lStateTransition                  = lRunningJump.AddTransition(lRunJump_RunForward);
            lStateTransition.hasExitTime      = false;
            lStateTransition.hasFixedDuration = true;
            lStateTransition.exitTime         = 0.8280886f;
            lStateTransition.duration         = 0.2499999f;
            lStateTransition.offset           = 0.2955611f;
            lStateTransition.mute             = false;
            lStateTransition.solo             = false;
            lStateTransition.AddCondition(UnityEditor.Animations.AnimatorConditionMode.Equals, 27545f, "L0MotionPhase");

            lStateTransition                  = lRunningJump.AddTransition(lLandToIdle);
            lStateTransition.hasExitTime      = false;
            lStateTransition.hasFixedDuration = true;
            lStateTransition.exitTime         = 0.8032071f;
            lStateTransition.duration         = 0.1951104f;
            lStateTransition.offset           = 0f;
            lStateTransition.mute             = false;
            lStateTransition.solo             = false;
            lStateTransition.AddCondition(UnityEditor.Animations.AnimatorConditionMode.Equals, 27540f, "L0MotionPhase");

            lStateTransition                  = lLandToIdle.AddTransition(lIdlePose);
            lStateTransition.hasExitTime      = true;
            lStateTransition.hasFixedDuration = true;
            lStateTransition.exitTime         = 0.6590909f;
            lStateTransition.duration         = 0.25f;
            lStateTransition.offset           = 0f;
            lStateTransition.mute             = false;
            lStateTransition.solo             = false;
        }
예제 #15
0
        /// <summary>
        /// Creates the animator substate machine for this motion.
        /// </summary>
        protected override void CreateStateMachine()
        {
            // Grab the root sm for the layer
            UnityEditor.Animations.AnimatorStateMachine lRootStateMachine    = _EditorAnimatorController.layers[mMotionLayer.AnimatorLayerIndex].stateMachine;
            UnityEditor.Animations.AnimatorStateMachine lSM_23510            = _EditorAnimatorController.layers[mMotionLayer.AnimatorLayerIndex].stateMachine;
            UnityEditor.Animations.AnimatorStateMachine lRootSubStateMachine = null;

            // If we find the sm with our name, remove it
            for (int i = 0; i < lRootStateMachine.stateMachines.Length; i++)
            {
                // Look for a sm with the matching name
                if (lRootStateMachine.stateMachines[i].stateMachine.name == _EditorAnimatorSMName)
                {
                    lRootSubStateMachine = lRootStateMachine.stateMachines[i].stateMachine;

                    // Allow the user to stop before we remove the sm
                    if (!UnityEditor.EditorUtility.DisplayDialog("Motion Controller", _EditorAnimatorSMName + " already exists. Delete and recreate it?", "Yes", "No"))
                    {
                        return;
                    }

                    // Remove the sm
                    //lRootStateMachine.RemoveStateMachine(lRootStateMachine.stateMachines[i].stateMachine);
                    break;
                }
            }

            UnityEditor.Animations.AnimatorStateMachine lSM_23512 = lRootSubStateMachine;
            if (lSM_23512 != null)
            {
                for (int i = lSM_23512.entryTransitions.Length - 1; i >= 0; i--)
                {
                    lSM_23512.RemoveEntryTransition(lSM_23512.entryTransitions[i]);
                }

                for (int i = lSM_23512.anyStateTransitions.Length - 1; i >= 0; i--)
                {
                    lSM_23512.RemoveAnyStateTransition(lSM_23512.anyStateTransitions[i]);
                }

                for (int i = lSM_23512.states.Length - 1; i >= 0; i--)
                {
                    lSM_23512.RemoveState(lSM_23512.states[i].state);
                }

                for (int i = lSM_23512.stateMachines.Length - 1; i >= 0; i--)
                {
                    lSM_23512.RemoveStateMachine(lSM_23512.stateMachines[i].stateMachine);
                }
            }
            else
            {
                lSM_23512 = lSM_23510.AddStateMachine(_EditorAnimatorSMName, new Vector3(408, -84, 0));
            }

            UnityEditor.Animations.AnimatorState lS_N18490 = lSM_23512.AddState("TreadIdlePose", new Vector3(600, 72, 0));
            lS_N18490.speed  = 1f;
            lS_N18490.motion = m15640;

            UnityEditor.Animations.AnimatorState lS_N18492 = lSM_23512.AddState("Swim Tree", new Vector3(312, 120, 0));
            lS_N18492.speed = 1f;

            UnityEditor.Animations.BlendTree lM_N18494 = CreateBlendTree("Swim Blend Tree", _EditorAnimatorController, mMotionLayer.AnimatorLayerIndex);
            lM_N18494.blendType       = UnityEditor.Animations.BlendTreeType.Simple1D;
            lM_N18494.blendParameter  = "InputMagnitude";
            lM_N18494.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_N18494.useAutomaticThresholds = false;
#endif
            lM_N18494.AddChild(m15642, 0f);

            UnityEditor.Animations.BlendTree lM_N18498 = CreateBlendTree("TreadTree", _EditorAnimatorController, mMotionLayer.AnimatorLayerIndex);
            lM_N18498.blendType       = UnityEditor.Animations.BlendTreeType.SimpleDirectional2D;
            lM_N18498.blendParameter  = "InputX";
            lM_N18498.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_N18498.useAutomaticThresholds = true;
#endif
            lM_N18498.AddChild(m15642, new Vector2(0f, 0.1f));
            lM_N18498.AddChild(m15642, new Vector2(-0.1f, 0f));
            lM_N18498.AddChild(m15642, new Vector2(0.1f, 0f));
            lM_N18498.AddChild(m15642, new Vector2(0f, -0.1f));
            lM_N18494.AddChild(lM_N18498, 0.5f);

            UnityEditor.Animations.BlendTree lM_N18502 = CreateBlendTree("SwimTree", _EditorAnimatorController, mMotionLayer.AnimatorLayerIndex);
            lM_N18502.blendType       = UnityEditor.Animations.BlendTreeType.SimpleDirectional2D;
            lM_N18502.blendParameter  = "InputX";
            lM_N18502.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_N18502.useAutomaticThresholds = true;
#endif
            lM_N18502.AddChild(m17384, new Vector2(0f, 0.1f));
            lM_N18502.AddChild(m17382, new Vector2(-0.1f, 0f));
            lM_N18502.AddChild(m17386, new Vector2(0.1f, 0f));
            lM_N18502.AddChild(m15642, new Vector2(0f, -0.1f));
            lM_N18494.AddChild(lM_N18502, 1f);
            lS_N18492.motion = lM_N18494;

            UnityEditor.Animations.AnimatorState lS_N18506 = lSM_23512.AddState("IdlePose", new Vector3(600, 156, 0));
            lS_N18506.speed  = 1f;
            lS_N18506.motion = m14222;

            // Create the transition from the any state. Note that 'AnyState' transitions have to be added to the root
            UnityEditor.Animations.AnimatorStateTransition lT_N18508 = lRootStateMachine.AddAnyStateTransition(lS_N18492);
            lT_N18508.hasExitTime      = false;
            lT_N18508.hasFixedDuration = true;
            lT_N18508.exitTime         = 0.9f;
            lT_N18508.duration         = 0.4f;
            lT_N18508.offset           = 0f;
            lT_N18508.mute             = false;
            lT_N18508.solo             = false;
            lT_N18508.AddCondition(UnityEditor.Animations.AnimatorConditionMode.Equals, 31400f, "L0MotionPhase");

            UnityEditor.Animations.AnimatorStateTransition lT_N18510 = lS_N18490.AddTransition(lS_N18492);
            lT_N18510.hasExitTime         = false;
            lT_N18510.hasFixedDuration    = true;
            lT_N18510.exitTime            = 0f;
            lT_N18510.duration            = 0.2f;
            lT_N18510.offset              = 0f;
            lT_N18510.mute                = false;
            lT_N18510.solo                = false;
            lT_N18510.canTransitionToSelf = true;
            lT_N18510.AddCondition(UnityEditor.Animations.AnimatorConditionMode.Greater, 0.1f, "InputMagnitude");

            UnityEditor.Animations.AnimatorStateTransition lT_N18512 = lS_N18492.AddTransition(lS_N18490);
            lT_N18512.hasExitTime         = false;
            lT_N18512.hasFixedDuration    = true;
            lT_N18512.exitTime            = 1f;
            lT_N18512.duration            = 0.3f;
            lT_N18512.offset              = 0f;
            lT_N18512.mute                = false;
            lT_N18512.solo                = false;
            lT_N18512.canTransitionToSelf = true;
            lT_N18512.AddCondition(UnityEditor.Animations.AnimatorConditionMode.Equals, 31405f, "L0MotionPhase");
            lT_N18512.AddCondition(UnityEditor.Animations.AnimatorConditionMode.Equals, 0f, "L0MotionParameter");

            UnityEditor.Animations.AnimatorStateTransition lT_N18514 = lS_N18492.AddTransition(lS_N18506);
            lT_N18514.hasExitTime         = false;
            lT_N18514.hasFixedDuration    = true;
            lT_N18514.exitTime            = 0.9286847f;
            lT_N18514.duration            = 0.25f;
            lT_N18514.offset              = 0f;
            lT_N18514.mute                = false;
            lT_N18514.solo                = false;
            lT_N18514.canTransitionToSelf = true;
            lT_N18514.AddCondition(UnityEditor.Animations.AnimatorConditionMode.Equals, 31406f, "L0MotionPhase");
        }
예제 #16
0
        /// <summary>
        /// Creates the animator substate machine for this motion.
        /// </summary>
        protected override void CreateStateMachine()
        {
            // Grab the root sm for the layer
            UnityEditor.Animations.AnimatorStateMachine lRootStateMachine = _EditorAnimatorController.layers[mMotionLayer.AnimatorLayerIndex].stateMachine;

            // If we find the sm with our name, remove it
            for (int i = 0; i < lRootStateMachine.stateMachines.Length; i++)
            {
                // Look for a sm with the matching name
                if (lRootStateMachine.stateMachines[i].stateMachine.name == _EditorAnimatorSMName)
                {
                    // Allow the user to stop before we remove the sm
                    if (!UnityEditor.EditorUtility.DisplayDialog("Motion Controller", _EditorAnimatorSMName + " already exists. Delete and recreate it?", "Yes", "No"))
                    {
                        return;
                    }

                    // Remove the sm
                    lRootStateMachine.RemoveStateMachine(lRootStateMachine.stateMachines[i].stateMachine);
                }
            }

            UnityEditor.Animations.AnimatorStateMachine lMotionStateMachine = lRootStateMachine.AddStateMachine(_EditorAnimatorSMName);

            // Attach the behaviour if needed
            if (_EditorAttachBehaviour)
            {
                MotionControllerBehaviour lBehaviour = lMotionStateMachine.AddStateMachineBehaviour(typeof(MotionControllerBehaviour)) as MotionControllerBehaviour;
                lBehaviour._MotionKey = (_Key.Length > 0 ? _Key : this.GetType().FullName);
            }

            UnityEditor.Animations.AnimatorState lWalkVault_1m = lMotionStateMachine.AddState("WalkVault_1m", new Vector3(348, 12, 0));
            lWalkVault_1m.motion = mWalkVault_1m;
            lWalkVault_1m.speed  = 1f;

            UnityEditor.Animations.AnimatorState lWalkForward = lMotionStateMachine.AddState("WalkForward", new Vector3(600, 12, 0));
            lWalkForward.motion = mWalkForward;
            lWalkForward.speed  = 1f;

            UnityEditor.Animations.AnimatorState lRunVault_1m = lMotionStateMachine.AddState("RunVault_1m", new Vector3(348, 96, 0));
            lRunVault_1m.motion = mRunVault_1m;
            lRunVault_1m.speed  = 1f;

            UnityEditor.Animations.AnimatorState lRunForward = lMotionStateMachine.AddState("RunForward", new Vector3(600, 96, 0));
            lRunForward.motion = mRunForward;
            lRunForward.speed  = 1f;

            UnityEditor.Animations.AnimatorStateTransition lAnyStateTransition = null;

            // Create the transition from the any state. Note that 'AnyState' transitions have to be added to the root
            lAnyStateTransition                  = lRootStateMachine.AddAnyStateTransition(lWalkVault_1m);
            lAnyStateTransition.hasExitTime      = false;
            lAnyStateTransition.hasFixedDuration = true;
            lAnyStateTransition.exitTime         = 0.9f;
            lAnyStateTransition.duration         = 0.1f;
            lAnyStateTransition.offset           = 0f;
            lAnyStateTransition.mute             = false;
            lAnyStateTransition.solo             = false;
            lAnyStateTransition.AddCondition(UnityEditor.Animations.AnimatorConditionMode.Equals, 1300f, "L0MotionPhase");

            // Create the transition from the any state. Note that 'AnyState' transitions have to be added to the root
            lAnyStateTransition                  = lRootStateMachine.AddAnyStateTransition(lRunVault_1m);
            lAnyStateTransition.hasExitTime      = false;
            lAnyStateTransition.hasFixedDuration = true;
            lAnyStateTransition.exitTime         = 0.9f;
            lAnyStateTransition.duration         = 0.1f;
            lAnyStateTransition.offset           = 0f;
            lAnyStateTransition.mute             = false;
            lAnyStateTransition.solo             = false;
            lAnyStateTransition.AddCondition(UnityEditor.Animations.AnimatorConditionMode.Equals, 1305f, "L0MotionPhase");

            UnityEditor.Animations.AnimatorStateTransition lStateTransition = null;

            lStateTransition                  = lWalkVault_1m.AddTransition(lWalkForward);
            lStateTransition.hasExitTime      = true;
            lStateTransition.hasFixedDuration = true;
            lStateTransition.exitTime         = 0.7967739f;
            lStateTransition.duration         = 0.103878f;
            lStateTransition.offset           = 0.0009236346f;
            lStateTransition.mute             = false;
            lStateTransition.solo             = false;

            lStateTransition                  = lRunVault_1m.AddTransition(lRunForward);
            lStateTransition.hasExitTime      = true;
            lStateTransition.hasFixedDuration = true;
            lStateTransition.exitTime         = 0.8584905f;
            lStateTransition.duration         = 0.2499999f;
            lStateTransition.offset           = 0.4060542f;
            lStateTransition.mute             = false;
            lStateTransition.solo             = false;
        }
예제 #17
0
        /// <summary>
        /// Creates the animator substate machine for this motion.
        /// </summary>
        protected override void CreateStateMachine()
        {
            // Grab the root sm for the layer
            UnityEditor.Animations.AnimatorStateMachine lRootStateMachine    = _EditorAnimatorController.layers[mMotionLayer.AnimatorLayerIndex].stateMachine;
            UnityEditor.Animations.AnimatorStateMachine lSM_38592            = _EditorAnimatorController.layers[mMotionLayer.AnimatorLayerIndex].stateMachine;
            UnityEditor.Animations.AnimatorStateMachine lRootSubStateMachine = null;

            // If we find the sm with our name, remove it
            for (int i = 0; i < lRootStateMachine.stateMachines.Length; i++)
            {
                // Look for a sm with the matching name
                if (lRootStateMachine.stateMachines[i].stateMachine.name == _EditorAnimatorSMName)
                {
                    lRootSubStateMachine = lRootStateMachine.stateMachines[i].stateMachine;

                    // Allow the user to stop before we remove the sm
                    if (!UnityEditor.EditorUtility.DisplayDialog("Motion Controller", _EditorAnimatorSMName + " already exists. Delete and recreate it?", "Yes", "No"))
                    {
                        return;
                    }

                    // Remove the sm
                    //lRootStateMachine.RemoveStateMachine(lRootStateMachine.stateMachines[i].stateMachine);
                    break;
                }
            }

            UnityEditor.Animations.AnimatorStateMachine lSM_N2165318 = lRootSubStateMachine;
            if (lSM_N2165318 != null)
            {
                for (int i = lSM_N2165318.entryTransitions.Length - 1; i >= 0; i--)
                {
                    lSM_N2165318.RemoveEntryTransition(lSM_N2165318.entryTransitions[i]);
                }

                for (int i = lSM_N2165318.anyStateTransitions.Length - 1; i >= 0; i--)
                {
                    lSM_N2165318.RemoveAnyStateTransition(lSM_N2165318.anyStateTransitions[i]);
                }

                for (int i = lSM_N2165318.states.Length - 1; i >= 0; i--)
                {
                    lSM_N2165318.RemoveState(lSM_N2165318.states[i].state);
                }

                for (int i = lSM_N2165318.stateMachines.Length - 1; i >= 0; i--)
                {
                    lSM_N2165318.RemoveStateMachine(lSM_N2165318.stateMachines[i].stateMachine);
                }
            }
            else
            {
                lSM_N2165318 = lSM_38592.AddStateMachine(_EditorAnimatorSMName, new Vector3(420, 324, 0));
            }

            UnityEditor.Animations.AnimatorState lS_N2165320 = lSM_N2165318.AddState("IdlePose Out", new Vector3(600, 120, 0));
            lS_N2165320.speed  = 1f;
            lS_N2165320.motion = m19780;

            UnityEditor.Animations.AnimatorState lS_N2165322 = lSM_N2165318.AddState("Move Tree", new Vector3(312, 120, 0));
            lS_N2165322.speed = 1f;

            UnityEditor.Animations.BlendTree lM_N2165324 = CreateBlendTree("Move Blend Tree", _EditorAnimatorController, mMotionLayer.AnimatorLayerIndex);
            lM_N2165324.blendType       = UnityEditor.Animations.BlendTreeType.Simple1D;
            lM_N2165324.blendParameter  = "InputMagnitude";
            lM_N2165324.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_N2165324.useAutomaticThresholds = true;
#endif
            lM_N2165324.AddChild(m19780, 0f);

            UnityEditor.Animations.BlendTree lM_N2165328 = CreateBlendTree("WalkTree", _EditorAnimatorController, mMotionLayer.AnimatorLayerIndex);
            lM_N2165328.blendType       = UnityEditor.Animations.BlendTreeType.SimpleDirectional2D;
            lM_N2165328.blendParameter  = "InputX";
            lM_N2165328.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_N2165328.useAutomaticThresholds = true;
#endif
            lM_N2165328.AddChild(m17768, new Vector2(0f, 0.35f));
            UnityEditor.Animations.ChildMotion[] lM_N2165328_0_Children = lM_N2165328.children;
            lM_N2165328_0_Children[lM_N2165328_0_Children.Length - 1].mirror    = false;
            lM_N2165328_0_Children[lM_N2165328_0_Children.Length - 1].timeScale = 1f;
            lM_N2165328.children = lM_N2165328_0_Children;

            lM_N2165328.AddChild(m23934, new Vector2(-0.35f, 0f));
            UnityEditor.Animations.ChildMotion[] lM_N2165328_1_Children = lM_N2165328.children;
            lM_N2165328_1_Children[lM_N2165328_1_Children.Length - 1].mirror    = false;
            lM_N2165328_1_Children[lM_N2165328_1_Children.Length - 1].timeScale = 1f;
            lM_N2165328.children = lM_N2165328_1_Children;

            lM_N2165328.AddChild(m25304, new Vector2(0.35f, 0f));
            UnityEditor.Animations.ChildMotion[] lM_N2165328_2_Children = lM_N2165328.children;
            lM_N2165328_2_Children[lM_N2165328_2_Children.Length - 1].mirror    = false;
            lM_N2165328_2_Children[lM_N2165328_2_Children.Length - 1].timeScale = 1f;
            lM_N2165328.children = lM_N2165328_2_Children;

            lM_N2165328.AddChild(m15900, new Vector2(0f, -0.35f));
            UnityEditor.Animations.ChildMotion[] lM_N2165328_3_Children = lM_N2165328.children;
            lM_N2165328_3_Children[lM_N2165328_3_Children.Length - 1].mirror    = false;
            lM_N2165328_3_Children[lM_N2165328_3_Children.Length - 1].timeScale = 1f;
            lM_N2165328.children = lM_N2165328_3_Children;

            lM_N2165324.AddChild(lM_N2165328, 0.5f);

            UnityEditor.Animations.BlendTree lM_N2165332 = CreateBlendTree("RunTree", _EditorAnimatorController, mMotionLayer.AnimatorLayerIndex);
            lM_N2165332.blendType       = UnityEditor.Animations.BlendTreeType.SimpleDirectional2D;
            lM_N2165332.blendParameter  = "InputX";
            lM_N2165332.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_N2165332.useAutomaticThresholds = true;
#endif
            lM_N2165332.AddChild(m16640, new Vector2(0f, 0.7f));
            UnityEditor.Animations.ChildMotion[] lM_N2165332_0_Children = lM_N2165332.children;
            lM_N2165332_0_Children[lM_N2165332_0_Children.Length - 1].mirror    = false;
            lM_N2165332_0_Children[lM_N2165332_0_Children.Length - 1].timeScale = 1f;
            lM_N2165332.children = lM_N2165332_0_Children;

            lM_N2165332.AddChild(m15614, new Vector2(-0.7f, 0f));
            UnityEditor.Animations.ChildMotion[] lM_N2165332_1_Children = lM_N2165332.children;
            lM_N2165332_1_Children[lM_N2165332_1_Children.Length - 1].mirror    = false;
            lM_N2165332_1_Children[lM_N2165332_1_Children.Length - 1].timeScale = 1f;
            lM_N2165332.children = lM_N2165332_1_Children;

            lM_N2165332.AddChild(m24920, new Vector2(0.7f, 0f));
            UnityEditor.Animations.ChildMotion[] lM_N2165332_2_Children = lM_N2165332.children;
            lM_N2165332_2_Children[lM_N2165332_2_Children.Length - 1].mirror    = false;
            lM_N2165332_2_Children[lM_N2165332_2_Children.Length - 1].timeScale = 1f;
            lM_N2165332.children = lM_N2165332_2_Children;

            lM_N2165332.AddChild(m16328, new Vector2(0f, -0.7f));
            UnityEditor.Animations.ChildMotion[] lM_N2165332_3_Children = lM_N2165332.children;
            lM_N2165332_3_Children[lM_N2165332_3_Children.Length - 1].mirror    = false;
            lM_N2165332_3_Children[lM_N2165332_3_Children.Length - 1].timeScale = 1f;
            lM_N2165332.children = lM_N2165332_3_Children;

            lM_N2165324.AddChild(lM_N2165332, 1f);
            lS_N2165322.motion = lM_N2165324;

            // Create the transition from the any state. Note that 'AnyState' transitions have to be added to the root
            UnityEditor.Animations.AnimatorStateTransition lT_N2165336 = lRootStateMachine.AddAnyStateTransition(lS_N2165322);
            lT_N2165336.hasExitTime         = false;
            lT_N2165336.hasFixedDuration    = true;
            lT_N2165336.exitTime            = 0.9f;
            lT_N2165336.duration            = 0.4f;
            lT_N2165336.offset              = 0f;
            lT_N2165336.mute                = false;
            lT_N2165336.solo                = false;
            lT_N2165336.canTransitionToSelf = true;
            lT_N2165336.interruptionSource  = (UnityEditor.Animations.TransitionInterruptionSource) 0;
            lT_N2165336.AddCondition(UnityEditor.Animations.AnimatorConditionMode.Equals, 32210f, "L0MotionPhase");

            UnityEditor.Animations.AnimatorStateTransition lT_N2165338 = lS_N2165320.AddTransition(lS_N2165322);
            lT_N2165338.hasExitTime         = false;
            lT_N2165338.hasFixedDuration    = true;
            lT_N2165338.exitTime            = 0f;
            lT_N2165338.duration            = 0.25f;
            lT_N2165338.offset              = 0f;
            lT_N2165338.mute                = false;
            lT_N2165338.solo                = false;
            lT_N2165338.canTransitionToSelf = true;
            lT_N2165338.interruptionSource  = (UnityEditor.Animations.TransitionInterruptionSource) 0;
            lT_N2165338.AddCondition(UnityEditor.Animations.AnimatorConditionMode.Greater, 0.1f, "InputMagnitude");

            UnityEditor.Animations.AnimatorStateTransition lT_N2165340 = lS_N2165322.AddTransition(lS_N2165320);
            lT_N2165340.hasExitTime         = false;
            lT_N2165340.hasFixedDuration    = true;
            lT_N2165340.exitTime            = 1f;
            lT_N2165340.duration            = 0.25f;
            lT_N2165340.offset              = 0f;
            lT_N2165340.mute                = false;
            lT_N2165340.solo                = false;
            lT_N2165340.canTransitionToSelf = true;
            lT_N2165340.interruptionSource  = (UnityEditor.Animations.TransitionInterruptionSource) 0;
            lT_N2165340.AddCondition(UnityEditor.Animations.AnimatorConditionMode.Equals, 32215f, "L0MotionPhase");
            lT_N2165340.AddCondition(UnityEditor.Animations.AnimatorConditionMode.Equals, 0f, "L0MotionParameter");
        }
        /// <summary>
        /// Init this instance.
        /// </summary>
        virtual protected void Init()
        {
            // Get character reference
            myCharacter = (IMob)gameObject.GetComponent(typeof(IMob));
            if (myCharacter == null)
            {
                myCharacter = (IMob)gameObject.GetComponentInParent(typeof(IMob));
            }
            if (myCharacter == null)
            {
                Debug.LogError("Mecanim Animation Bridge (3D) unable to find Character or Enemy reference");
            }

            if (myCharacter != null)
            {
                // Events
                myCharacter.ChangeAnimationState += AnimationStateChanged;
                if (myCharacter is Character)
                {
                    ((Character)myCharacter).Respawned += HandleRespawned;
                }

                myAnimator = GetComponentInChildren <Animator>();
                if (myAnimator == null)
                {
                    Debug.LogError("Platform Animator unable to find Unity Animator reference");
                }
                defaultController = myAnimator.runtimeAnimatorController;

                // Get an aimer if one is present
                ProjectileAimer tmpAimer = ((Component)myCharacter).gameObject.GetComponent <ProjectileAimer> ();
                if (tmpAimer != null && myCharacter is Character && (tmpAimer.aimType == ProjectileAimingTypes.EIGHT_WAY || tmpAimer.aimType == ProjectileAimingTypes.SIX_WAY))
                {
                    aimer = tmpAimer;
                }

                // Set up animation overrides
                animationStateOverrideLookup = new Dictionary <string, AnimatorOverrideController> ();
                foreach (AnimatorControllerMapping mapping in mappings)
                {
                    animationStateOverrideLookup.Add(mapping.overrrideState, mapping.controller);
                }
            }
#if UNITY_EDITOR
        #if UNITY_5
            // In editor mode build a list of handled states for error messaging and the like
            if (myAnimator.runtimeAnimatorController is UnityEditor.Animations.AnimatorController)
            {
                editor_stateNames = new List <string>();
                UnityEditor.Animations.AnimatorStateMachine stateMachine = ((UnityEditor.Animations.AnimatorController)defaultController).layers[0].stateMachine;
                for (int i = 0; i < stateMachine.states.Length; i++)
                {
                    editor_stateNames.Add(stateMachine.states[i].state.name);
                }
                if (!editor_stateNames.Contains("IDLE"))
                {
                    Debug.LogWarning("Its recommended that you have a default state called 'IDLE' which can act as a hard reset state for actions like respawning");
                }
            }
        #else
            // In editor mode build a list of handled states for error messaging and the like
            if (myAnimator.runtimeAnimatorController is UnityEditorInternal.AnimatorController)
            {
                editor_stateNames = new List <string>();
                UnityEditorInternal.StateMachine stateMachine = ((UnityEditorInternal.AnimatorController)defaultController).GetLayer(0).stateMachine;
                for (int i = 0; i < stateMachine.stateCount; i++)
                {
                    editor_stateNames.Add(stateMachine.GetState(i).name);
                }
                if (!editor_stateNames.Contains("IDLE"))
                {
                    Debug.LogWarning("Its recommended that you have a default state called 'IDLE' which can act as a hard reset state for actions like respawning");
                }
            }
        #endif
#endif
        }
예제 #19
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_31068 = MotionControllerMotion.EditorFindSSM(lLayerStateMachine, "BasicJump-SM");
            if (lSSM_31068 == null)
            {
                lSSM_31068 = lLayerStateMachine.AddStateMachine("BasicJump-SM", new Vector3(192, -864, 0));
            }

            UnityEditor.Animations.AnimatorState lState_31422 = MotionControllerMotion.EditorFindState(lSSM_31068, "Unarmed Jump");
            if (lState_31422 == null)
            {
                lState_31422 = lSSM_31068.AddState("Unarmed Jump", new Vector3(360, -60, 0));
            }
            lState_31422.speed  = 1.1f;
            lState_31422.mirror = false;
            lState_31422.tag    = "";
            lState_31422.motion = MotionControllerMotion.EditorFindAnimationClip("Assets/ootii/Assets/MotionController/Content/Animations/Humanoid/Jumping/ootii_StandingJump.fbx", "StandingJump");

            UnityEditor.Animations.AnimatorState lState_32404 = MotionControllerMotion.EditorFindState(lSSM_31068, "IdlePose");
            if (lState_32404 == null)
            {
                lState_32404 = lSSM_31068.AddState("IdlePose", new Vector3(600, -60, 0));
            }
            lState_32404.speed  = 1f;
            lState_32404.mirror = false;
            lState_32404.tag    = "Exit";
            lState_32404.motion = MotionControllerMotion.EditorFindAnimationClip("Assets/ootii/Assets/MotionController/Content/Animations/Humanoid/Idling/unity_Idle_IdleToIdlesR.fbx", "IdlePose");

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

            UnityEditor.Animations.AnimatorStateTransition lTransition_32406 = MotionControllerMotion.EditorFindTransition(lState_31422, lState_32404, 0);
            if (lTransition_32406 == null)
            {
                lTransition_32406 = lState_31422.AddTransition(lState_32404);
            }
            lTransition_32406.isExit              = false;
            lTransition_32406.hasExitTime         = true;
            lTransition_32406.hasFixedDuration    = true;
            lTransition_32406.exitTime            = 0.7643284f;
            lTransition_32406.duration            = 0.25f;
            lTransition_32406.offset              = 0f;
            lTransition_32406.mute                = false;
            lTransition_32406.solo                = false;
            lTransition_32406.canTransitionToSelf = true;
            lTransition_32406.interruptionSource  = (UnityEditor.Animations.TransitionInterruptionSource) 0;
            for (int i = lTransition_32406.conditions.Length - 1; i >= 0; i--)
            {
                lTransition_32406.RemoveCondition(lTransition_32406.conditions[i]);
            }

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

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

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

            // Run any post processing after creating the state machine
            OnStateMachineCreated();
        }
예제 #20
0
        /// <summary>
        /// Creates the animator substate machine for this motion.
        /// </summary>
        protected override void CreateStateMachine()
        {
            // Grab the root sm for the layer
            UnityEditor.Animations.AnimatorStateMachine lRootStateMachine    = _EditorAnimatorController.layers[mMotionLayer.AnimatorLayerIndex].stateMachine;
            UnityEditor.Animations.AnimatorStateMachine lSM_23510            = _EditorAnimatorController.layers[mMotionLayer.AnimatorLayerIndex].stateMachine;
            UnityEditor.Animations.AnimatorStateMachine lRootSubStateMachine = null;

            // If we find the sm with our name, remove it
            for (int i = 0; i < lRootStateMachine.stateMachines.Length; i++)
            {
                // Look for a sm with the matching name
                if (lRootStateMachine.stateMachines[i].stateMachine.name == _EditorAnimatorSMName)
                {
                    lRootSubStateMachine = lRootStateMachine.stateMachines[i].stateMachine;

                    // Allow the user to stop before we remove the sm
                    if (!UnityEditor.EditorUtility.DisplayDialog("Motion Controller", _EditorAnimatorSMName + " already exists. Delete and recreate it?", "Yes", "No"))
                    {
                        return;
                    }

                    // Remove the sm
                    //lRootStateMachine.RemoveStateMachine(lRootStateMachine.stateMachines[i].stateMachine);
                    break;
                }
            }

            UnityEditor.Animations.AnimatorStateMachine lSM_N25356 = lRootSubStateMachine;
            if (lSM_N25356 != null)
            {
                for (int i = lSM_N25356.entryTransitions.Length - 1; i >= 0; i--)
                {
                    lSM_N25356.RemoveEntryTransition(lSM_N25356.entryTransitions[i]);
                }

                for (int i = lSM_N25356.anyStateTransitions.Length - 1; i >= 0; i--)
                {
                    lSM_N25356.RemoveAnyStateTransition(lSM_N25356.anyStateTransitions[i]);
                }

                for (int i = lSM_N25356.states.Length - 1; i >= 0; i--)
                {
                    lSM_N25356.RemoveState(lSM_N25356.states[i].state);
                }

                for (int i = lSM_N25356.stateMachines.Length - 1; i >= 0; i--)
                {
                    lSM_N25356.RemoveStateMachine(lSM_N25356.stateMachines[i].stateMachine);
                }
            }
            else
            {
                lSM_N25356 = lSM_23510.AddStateMachine(_EditorAnimatorSMName, new Vector3(636, -84, 0));
            }

            UnityEditor.Animations.AnimatorState lS_N25358 = lSM_N25356.AddState("run_to_dive", new Vector3(312, 132, 0));
            lS_N25358.speed  = 1f;
            lS_N25358.motion = m13726;

            UnityEditor.Animations.AnimatorState lS_N25360 = lSM_N25356.AddState("SwimIdlePose", new Vector3(576, 180, 0));
            lS_N25360.speed  = 1f;
            lS_N25360.motion = m17380;

            UnityEditor.Animations.AnimatorState lS_N25362 = lSM_N25356.AddState("StandingDive", new Vector3(312, 36, 0));
            lS_N25362.speed  = 1f;
            lS_N25362.motion = m18078;

            UnityEditor.Animations.AnimatorState lS_N25364 = lSM_N25356.AddState("TreadIdlePose", new Vector3(576, 96, 0));
            lS_N25364.speed  = 1f;
            lS_N25364.motion = m15640;

            // Create the transition from the any state. Note that 'AnyState' transitions have to be added to the root
            UnityEditor.Animations.AnimatorStateTransition lT_N25366 = lRootStateMachine.AddAnyStateTransition(lS_N25362);
            lT_N25366.hasExitTime      = false;
            lT_N25366.hasFixedDuration = true;
            lT_N25366.exitTime         = 0.9f;
            lT_N25366.duration         = 0.1f;
            lT_N25366.offset           = 0f;
            lT_N25366.mute             = false;
            lT_N25366.solo             = false;
            lT_N25366.AddCondition(UnityEditor.Animations.AnimatorConditionMode.Equals, 31500f, "L0MotionPhase");
            lT_N25366.AddCondition(UnityEditor.Animations.AnimatorConditionMode.Equals, 0f, "L0MotionParameter");

            // Create the transition from the any state. Note that 'AnyState' transitions have to be added to the root
            UnityEditor.Animations.AnimatorStateTransition lT_N25368 = lRootStateMachine.AddAnyStateTransition(lS_N25358);
            lT_N25368.hasExitTime      = false;
            lT_N25368.hasFixedDuration = true;
            lT_N25368.exitTime         = 0.9f;
            lT_N25368.duration         = 0.1f;
            lT_N25368.offset           = 0f;
            lT_N25368.mute             = false;
            lT_N25368.solo             = false;
            lT_N25368.AddCondition(UnityEditor.Animations.AnimatorConditionMode.Equals, 31500f, "L0MotionPhase");
            lT_N25368.AddCondition(UnityEditor.Animations.AnimatorConditionMode.Equals, 1f, "L0MotionParameter");

            UnityEditor.Animations.AnimatorStateTransition lT_N25370 = lS_N25358.AddTransition(lS_N25360);
            lT_N25370.hasExitTime         = false;
            lT_N25370.hasFixedDuration    = true;
            lT_N25370.exitTime            = 0.8834254f;
            lT_N25370.duration            = 0.25f;
            lT_N25370.offset              = 0f;
            lT_N25370.mute                = false;
            lT_N25370.solo                = false;
            lT_N25370.canTransitionToSelf = true;
            lT_N25370.AddCondition(UnityEditor.Animations.AnimatorConditionMode.Equals, 31501f, "L0MotionPhase");
            lT_N25370.AddCondition(UnityEditor.Animations.AnimatorConditionMode.Greater, 0.6f, "InputMagnitude");

            UnityEditor.Animations.AnimatorStateTransition lT_N25372 = lS_N25358.AddTransition(lS_N25364);
            lT_N25372.hasExitTime         = false;
            lT_N25372.hasFixedDuration    = true;
            lT_N25372.exitTime            = 0.7887324f;
            lT_N25372.duration            = 0.5f;
            lT_N25372.offset              = 0f;
            lT_N25372.mute                = false;
            lT_N25372.solo                = false;
            lT_N25372.canTransitionToSelf = true;
            lT_N25372.AddCondition(UnityEditor.Animations.AnimatorConditionMode.Equals, 31501f, "L0MotionPhase");
            lT_N25372.AddCondition(UnityEditor.Animations.AnimatorConditionMode.Less, 0.6f, "InputMagnitude");

            UnityEditor.Animations.AnimatorStateTransition lT_N25374 = lS_N25362.AddTransition(lS_N25358);
            lT_N25374.hasExitTime         = true;
            lT_N25374.hasFixedDuration    = true;
            lT_N25374.exitTime            = 0.6953372f;
            lT_N25374.duration            = 0.1499999f;
            lT_N25374.offset              = 0.3380885f;
            lT_N25374.mute                = false;
            lT_N25374.solo                = false;
            lT_N25374.canTransitionToSelf = true;
        }
예제 #21
0
        /// <summary>
        /// Creates the animator substate machine for this motion.
        /// </summary>
        protected override void CreateStateMachine()
        {
            // Grab the root sm for the layer
            UnityEditor.Animations.AnimatorStateMachine lRootStateMachine    = _EditorAnimatorController.layers[mMotionLayer.AnimatorLayerIndex].stateMachine;
            UnityEditor.Animations.AnimatorStateMachine lSM_23030            = _EditorAnimatorController.layers[mMotionLayer.AnimatorLayerIndex].stateMachine;
            UnityEditor.Animations.AnimatorStateMachine lRootSubStateMachine = null;

            // If we find the sm with our name, remove it
            for (int i = 0; i < lRootStateMachine.stateMachines.Length; i++)
            {
                // Look for a sm with the matching name
                if (lRootStateMachine.stateMachines[i].stateMachine.name == _EditorAnimatorSMName)
                {
                    lRootSubStateMachine = lRootStateMachine.stateMachines[i].stateMachine;

                    // Allow the user to stop before we remove the sm
                    if (!UnityEditor.EditorUtility.DisplayDialog("Motion Controller", _EditorAnimatorSMName + " already exists. Delete and recreate it?", "Yes", "No"))
                    {
                        return;
                    }

                    // Remove the sm
                    //lRootStateMachine.RemoveStateMachine(lRootStateMachine.stateMachines[i].stateMachine);
                    break;
                }
            }

            UnityEditor.Animations.AnimatorStateMachine lSM_24308 = lRootSubStateMachine;
            if (lSM_24308 != null)
            {
                for (int i = lSM_24308.entryTransitions.Length - 1; i >= 0; i--)
                {
                    lSM_24308.RemoveEntryTransition(lSM_24308.entryTransitions[i]);
                }

                for (int i = lSM_24308.anyStateTransitions.Length - 1; i >= 0; i--)
                {
                    lSM_24308.RemoveAnyStateTransition(lSM_24308.anyStateTransitions[i]);
                }

                for (int i = lSM_24308.states.Length - 1; i >= 0; i--)
                {
                    lSM_24308.RemoveState(lSM_24308.states[i].state);
                }

                for (int i = lSM_24308.stateMachines.Length - 1; i >= 0; i--)
                {
                    lSM_24308.RemoveStateMachine(lSM_24308.stateMachines[i].stateMachine);
                }
            }
            else
            {
                lSM_24308 = lSM_23030.AddStateMachine(_EditorAnimatorSMName, new Vector3(48, 12, 0));
            }

            UnityEditor.Animations.AnimatorState lS_24312 = lSM_24308.AddState("Punch", new Vector3(276, 12, 0));
            lS_24312.speed  = 1f;
            lS_24312.motion = m17128;

            // Create the transition from the any state. Note that 'AnyState' transitions have to be added to the root
            UnityEditor.Animations.AnimatorStateTransition lT_24310 = lRootStateMachine.AddAnyStateTransition(lS_24312);
            lT_24310.hasExitTime         = false;
            lT_24310.hasFixedDuration    = false;
            lT_24310.exitTime            = 0.9f;
            lT_24310.duration            = 0.1f;
            lT_24310.offset              = 0f;
            lT_24310.mute                = false;
            lT_24310.solo                = false;
            lT_24310.canTransitionToSelf = true;
            lT_24310.interruptionSource  = (UnityEditor.Animations.TransitionInterruptionSource) 0;
            lT_24310.AddCondition(UnityEditor.Animations.AnimatorConditionMode.Equals, 500f, "L1MotionPhase");

            UnityEditor.Animations.AnimatorStateTransition lT_24314 = lS_24312.AddTransition(lRootStateMachine);
            lT_24314.hasExitTime         = true;
            lT_24314.hasFixedDuration    = true;
            lT_24314.exitTime            = 0.8f;
            lT_24314.duration            = 0.2f;
            lT_24314.offset              = 0f;
            lT_24314.mute                = false;
            lT_24314.solo                = false;
            lT_24314.canTransitionToSelf = true;
            lT_24314.interruptionSource  = (UnityEditor.Animations.TransitionInterruptionSource) 0;
        }
예제 #22
0
        void CheckResources()
        {
            ActiveTextures.Clear();
            ActiveMaterials.Clear();
            ActiveMeshDetails.Clear();
            MissingObjects.Clear();
            thingsMissing = false;

            Renderer[] renderers = FindObjects <Renderer>();

            MaterialDetails skyMat = new MaterialDetails();

            skyMat.material = RenderSettings.skybox;
            skyMat.isSky    = true;
            ActiveMaterials.Add(skyMat);

            //Debug.Log("Total renderers "+renderers.Length);
            foreach (Renderer renderer in renderers)
            {
                //Debug.Log("Renderer is "+renderer.name);
                foreach (Material material in renderer.sharedMaterials)
                {
                    MaterialDetails tMaterialDetails = FindMaterialDetails(material);
                    if (tMaterialDetails == null)
                    {
                        tMaterialDetails          = new MaterialDetails();
                        tMaterialDetails.material = material;
                        ActiveMaterials.Add(tMaterialDetails);
                    }
                    tMaterialDetails.FoundInRenderers.Add(renderer);
                }

                if (renderer is SpriteRenderer)
                {
                    SpriteRenderer tSpriteRenderer = (SpriteRenderer)renderer;

                    if (tSpriteRenderer.sprite != null)
                    {
                        var tSpriteTextureDetail = GetTextureDetail(tSpriteRenderer.sprite.texture, renderer);
                        if (!ActiveTextures.Contains(tSpriteTextureDetail))
                        {
                            ActiveTextures.Add(tSpriteTextureDetail);
                        }
                    }
                    else if (tSpriteRenderer.sprite == null)
                    {
                        MissingGraphic tMissing = new MissingGraphic();
                        tMissing.Object = tSpriteRenderer.transform;
                        tMissing.type   = "sprite";
                        tMissing.name   = tSpriteRenderer.transform.name;
                        MissingObjects.Add(tMissing);
                        thingsMissing = true;
                    }
                }
            }

            if (IncludeGuiElements)
            {
                Graphic[] graphics = FindObjects <Graphic>();

                foreach (Graphic graphic in graphics)
                {
                    if (graphic.mainTexture)
                    {
                        var tSpriteTextureDetail = GetTextureDetail(graphic.mainTexture, graphic);
                        if (!ActiveTextures.Contains(tSpriteTextureDetail))
                        {
                            ActiveTextures.Add(tSpriteTextureDetail);
                        }
                    }

                    if (graphic.materialForRendering)
                    {
                        MaterialDetails tMaterialDetails = FindMaterialDetails(graphic.materialForRendering);
                        if (tMaterialDetails == null)
                        {
                            tMaterialDetails          = new MaterialDetails();
                            tMaterialDetails.material = graphic.materialForRendering;
                            tMaterialDetails.isgui    = true;
                            ActiveMaterials.Add(tMaterialDetails);
                        }
                        tMaterialDetails.FoundInGraphics.Add(graphic);
                    }
                }

                Button[] buttons = FindObjects <Button>();
                foreach (Button button in buttons)
                {
                    CheckButtonSpriteState(button, button.spriteState.disabledSprite);
                    CheckButtonSpriteState(button, button.spriteState.highlightedSprite);
                    CheckButtonSpriteState(button, button.spriteState.pressedSprite);
                }
            }

            foreach (MaterialDetails tMaterialDetails in ActiveMaterials)
            {
                Material tMaterial = tMaterialDetails.material;
                if (tMaterial != null)
                {
                    var dependencies = EditorUtility.CollectDependencies(new UnityEngine.Object[] { tMaterial });
                    foreach (Object obj in dependencies)
                    {
                        if (obj is Texture)
                        {
                            Texture tTexture       = obj as Texture;
                            var     tTextureDetail = GetTextureDetail(tTexture, tMaterial, tMaterialDetails);
                            tTextureDetail.isSky    = tMaterialDetails.isSky;
                            tTextureDetail.instance = tMaterialDetails.instance;
                            tTextureDetail.isgui    = tMaterialDetails.isgui;
                            ActiveTextures.Add(tTextureDetail);
                        }
                    }

                    //if the texture was downloaded, it won't be included in the editor dependencies
                    if (tMaterial.HasProperty("_MainTex"))
                    {
                        if (tMaterial.mainTexture != null && !dependencies.Contains(tMaterial.mainTexture))
                        {
                            var tTextureDetail = GetTextureDetail(tMaterial.mainTexture, tMaterial, tMaterialDetails);
                            ActiveTextures.Add(tTextureDetail);
                        }
                    }
                }
            }


            MeshFilter[] meshFilters = FindObjects <MeshFilter>();

            foreach (MeshFilter tMeshFilter in meshFilters)
            {
                Mesh tMesh = tMeshFilter.sharedMesh;
                if (tMesh != null)
                {
                    MeshDetails tMeshDetails = FindMeshDetails(tMesh);
                    if (tMeshDetails == null)
                    {
                        tMeshDetails      = new MeshDetails();
                        tMeshDetails.mesh = tMesh;
                        ActiveMeshDetails.Add(tMeshDetails);
                    }
                    tMeshDetails.FoundInMeshFilters.Add(tMeshFilter);
                }
                else if (tMesh == null && tMeshFilter.transform.GetComponent("TextContainer") == null)
                {
                    MissingGraphic tMissing = new MissingGraphic();
                    tMissing.Object = tMeshFilter.transform;
                    tMissing.type   = "mesh";
                    tMissing.name   = tMeshFilter.transform.name;
                    MissingObjects.Add(tMissing);
                    thingsMissing = true;
                }

                var meshRenderrer = tMeshFilter.transform.GetComponent <MeshRenderer>();

                if (meshRenderrer == null || meshRenderrer.sharedMaterial == null)
                {
                    MissingGraphic tMissing = new MissingGraphic();
                    tMissing.Object = tMeshFilter.transform;
                    tMissing.type   = "material";
                    tMissing.name   = tMeshFilter.transform.name;
                    MissingObjects.Add(tMissing);
                    thingsMissing = true;
                }
            }

            SkinnedMeshRenderer[] skinnedMeshRenderers = FindObjects <SkinnedMeshRenderer>();

            foreach (SkinnedMeshRenderer tSkinnedMeshRenderer in skinnedMeshRenderers)
            {
                Mesh tMesh = tSkinnedMeshRenderer.sharedMesh;
                if (tMesh != null)
                {
                    MeshDetails tMeshDetails = FindMeshDetails(tMesh);
                    if (tMeshDetails == null)
                    {
                        tMeshDetails      = new MeshDetails();
                        tMeshDetails.mesh = tMesh;
                        ActiveMeshDetails.Add(tMeshDetails);
                    }
                    tMeshDetails.FoundInSkinnedMeshRenderer.Add(tSkinnedMeshRenderer);
                }
                else if (tMesh == null)
                {
                    MissingGraphic tMissing = new MissingGraphic();
                    tMissing.Object = tSkinnedMeshRenderer.transform;
                    tMissing.type   = "mesh";
                    tMissing.name   = tSkinnedMeshRenderer.transform.name;
                    MissingObjects.Add(tMissing);
                    thingsMissing = true;
                }
                if (tSkinnedMeshRenderer.sharedMaterial == null)
                {
                    MissingGraphic tMissing = new MissingGraphic();
                    tMissing.Object = tSkinnedMeshRenderer.transform;
                    tMissing.type   = "material";
                    tMissing.name   = tSkinnedMeshRenderer.transform.name;
                    MissingObjects.Add(tMissing);
                    thingsMissing = true;
                }
            }

            if (IncludeSpriteAnimations)
            {
                Animator[] animators = FindObjects <Animator>();
                foreach (Animator anim in animators)
                {
#if UNITY_4_6 || UNITY_4_5 || UNITY_4_4 || UNITY_4_3
                    UnityEditorInternal.AnimatorController ac = anim.runtimeAnimatorController as UnityEditorInternal.AnimatorController;
#elif UNITY_5 || UNITY_5_3_OR_NEWER
                    UnityEditor.Animations.AnimatorController ac = anim.runtimeAnimatorController as UnityEditor.Animations.AnimatorController;
#endif

                    //Skip animators without layers, this can happen if they don't have an animator controller.
                    if (!ac || ac.layers == null || ac.layers.Length == 0)
                    {
                        continue;
                    }

                    for (int x = 0; x < anim.layerCount; x++)
                    {
                        UnityEditor.Animations.AnimatorStateMachine sm = ac.layers[x].stateMachine;
                        int cnt = sm.states.Length;

                        for (int i = 0; i < cnt; i++)
                        {
                            UnityEditor.Animations.AnimatorState state = sm.states[i].state;
                            Motion m = state.motion;
                            if (m != null)
                            {
                                AnimationClip clip = m as AnimationClip;

                                if (clip != null)
                                {
                                    EditorCurveBinding[] ecbs = AnimationUtility.GetObjectReferenceCurveBindings(clip);

                                    foreach (EditorCurveBinding ecb in ecbs)
                                    {
                                        if (ecb.propertyName == "m_Sprite")
                                        {
                                            foreach (ObjectReferenceKeyframe keyframe in AnimationUtility.GetObjectReferenceCurve(clip, ecb))
                                            {
                                                Sprite tSprite = keyframe.value as Sprite;

                                                if (tSprite != null)
                                                {
                                                    var tTextureDetail = GetTextureDetail(tSprite.texture, anim);
                                                    if (!ActiveTextures.Contains(tTextureDetail))
                                                    {
                                                        ActiveTextures.Add(tTextureDetail);
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            if (IncludeScriptReferences)
            {
                MonoBehaviour[] scripts = FindObjects <MonoBehaviour>();
                foreach (MonoBehaviour script in scripts)
                {
                    BindingFlags flags  = BindingFlags.Public | BindingFlags.Instance; // only public non-static fields are bound to by Unity.
                    FieldInfo[]  fields = script.GetType().GetFields(flags);

                    foreach (FieldInfo field in fields)
                    {
                        System.Type fieldType = field.FieldType;
                        if (fieldType == typeof(Sprite))
                        {
                            Sprite tSprite = field.GetValue(script) as Sprite;
                            if (tSprite != null)
                            {
                                var tSpriteTextureDetail = GetTextureDetail(tSprite.texture, script);
                                if (!ActiveTextures.Contains(tSpriteTextureDetail))
                                {
                                    ActiveTextures.Add(tSpriteTextureDetail);
                                }
                            }
                        }
                        if (fieldType == typeof(Mesh))
                        {
                            Mesh tMesh = field.GetValue(script) as Mesh;
                            if (tMesh != null)
                            {
                                MeshDetails tMeshDetails = FindMeshDetails(tMesh);
                                if (tMeshDetails == null)
                                {
                                    tMeshDetails          = new MeshDetails();
                                    tMeshDetails.mesh     = tMesh;
                                    tMeshDetails.instance = true;
                                    ActiveMeshDetails.Add(tMeshDetails);
                                }
                            }
                        }
                        if (fieldType == typeof(Material))
                        {
                            Material tMaterial = field.GetValue(script) as Material;
                            if (tMaterial != null)
                            {
                                MaterialDetails tMatDetails = FindMaterialDetails(tMaterial);
                                if (tMatDetails == null)
                                {
                                    tMatDetails          = new MaterialDetails();
                                    tMatDetails.instance = true;
                                    tMatDetails.material = tMaterial;
                                    if (!ActiveMaterials.Contains(tMatDetails))
                                    {
                                        ActiveMaterials.Add(tMatDetails);
                                    }
                                }
                                if (tMaterial.mainTexture)
                                {
                                    var tSpriteTextureDetail = GetTextureDetail(tMaterial.mainTexture);
                                    if (!ActiveTextures.Contains(tSpriteTextureDetail))
                                    {
                                        ActiveTextures.Add(tSpriteTextureDetail);
                                    }
                                }
                                var dependencies = EditorUtility.CollectDependencies(new UnityEngine.Object[] { tMaterial });
                                foreach (Object obj in dependencies)
                                {
                                    if (obj is Texture)
                                    {
                                        Texture tTexture       = obj as Texture;
                                        var     tTextureDetail = GetTextureDetail(tTexture, tMaterial, tMatDetails);
                                        if (!ActiveTextures.Contains(tTextureDetail))
                                        {
                                            ActiveTextures.Add(tTextureDetail);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            TotalTextureMemory = 0;
            foreach (TextureDetails tTextureDetails in ActiveTextures)
            {
                TotalTextureMemory += tTextureDetails.memSizeKB;
            }

            TotalMeshVertices = 0;
            foreach (MeshDetails tMeshDetails in ActiveMeshDetails)
            {
                TotalMeshVertices += tMeshDetails.mesh.vertexCount;
            }

            // Sort by size, descending
            ActiveTextures.Sort(delegate(TextureDetails details1, TextureDetails details2) { return(details2.memSizeKB - details1.memSizeKB); });
            ActiveTextures = ActiveTextures.Distinct().ToList();
            ActiveMeshDetails.Sort(delegate(MeshDetails details1, MeshDetails details2) { return(details2.mesh.vertexCount - details1.mesh.vertexCount); });

            collectedInPlayingMode = Application.isPlaying;
        }
예제 #23
0
        /// <summary>
        /// Initialise this animation bridge.
        /// </summary>
        protected void Init()
        {
            // Get character reference
            myMob = (IMob)gameObject.GetComponent(typeof(IMob));
            if (myMob == null)
            {
                myMob = (IMob)gameObject.GetComponentInParent(typeof(IMob));
            }
            if (myMob == null)
            {
                Debug.LogError("Mecanim Animation Bridge (2D) unable to find Character or Enemy reference");
            }
            myMob.ChangeAnimationState += AnimationStateChanged;
            myAnimator = GetComponentInChildren <Animator>();
            if (myAnimator == null)
            {
                Debug.LogError("Platform Animator unable to find Unity Animator reference");
            }
            defaultController = myAnimator.runtimeAnimatorController;

            if (myMob is Character && (statesWithAimUpModifer.Count > 0 || statesWithAimDownModifer.Count > 0))
            {
                myCharacter = (Character)myMob;
                aimer       = myCharacter.GetComponentInChildren <ProjectileAimer>();
            }
            if ((statesWithAimUpModifer.Count > 0 || statesWithAimDownModifer.Count > 0) && aimer == null)
            {
                Debug.LogWarning("Can't use UP or DOWN modifiers as no aimer could be found");
            }

            animationStateOverrideLookup = new Dictionary <string, AnimatorOverrideController> ();
            foreach (AnimatorControllerMapping mapping in mappings)
            {
                animationStateOverrideLookup.Add(mapping.overrrideState, mapping.controller);
            }

            queuedStates     = new Queue <string> ();
            queuedPriorities = new Queue <int> ();
            state            = AnimationState.NONE.AsString();
            priority         = -1;

            TimeManager.Instance.GamePaused   += HandleGamePaused;
            TimeManager.Instance.GameUnPaused += HandleGameUnPaused;

#if UNITY_EDITOR
        #if UNITY_5
            // TODO also check for up and down states
            // In editor mode build a list of handled states for error messaging and the like
            if (myAnimator.runtimeAnimatorController is UnityEditor.Animations.AnimatorController)
            {
                editor_stateNames = new List <string>();
                UnityEditor.Animations.AnimatorStateMachine stateMachine = ((UnityEditor.Animations.AnimatorController)defaultController).layers[0].stateMachine;
                for (int i = 0; i < stateMachine.states.Length; i++)
                {
                    editor_stateNames.Add(stateMachine.states[i].state.name);
                }
            }
        #else
            // TODO also check for up and down states
            // In editor mode build a list of handled states for error messaging and the like
            if (myAnimator.runtimeAnimatorController is UnityEditorInternal.AnimatorController)
            {
                editor_stateNames = new List <string>();
                UnityEditorInternal.StateMachine stateMachine = ((UnityEditorInternal.AnimatorController)defaultController).GetLayer(0).stateMachine;
                for (int i = 0; i < stateMachine.stateCount; i++)
                {
                    editor_stateNames.Add(stateMachine.GetState(i).name);
                }
            }
        #endif
#endif
        }
예제 #24
0
 /// <summary>
 /// Clears the state machine.
 /// </summary>
 private void ClearPreviewStateMachine()
 {
     if (this.Animator != null) {
                         UnityEditor.Animations.AnimatorController.SetAnimatorController (this.Animator, null);
                 }
                 UnityEngine.Object.DestroyImmediate (this._previewAnimatorController);
                 UnityEngine.Object.DestroyImmediate (this._previewStateMachine);
                 UnityEngine.Object.DestroyImmediate (this._previewState);
                 _previewStateMachine = null;
                 _previewAnimatorController = null;
                 _previewState = null;
 }
예제 #25
0
        /// <summary>
        /// Creates the animator substate machine for this motion.
        /// </summary>
        protected override void CreateStateMachine()
        {
            // Grab the root sm for the layer
            UnityEditor.Animations.AnimatorStateMachine lRootStateMachine    = _EditorAnimatorController.layers[mMotionLayer.AnimatorLayerIndex].stateMachine;
            UnityEditor.Animations.AnimatorStateMachine lSM_41656            = _EditorAnimatorController.layers[mMotionLayer.AnimatorLayerIndex].stateMachine;
            UnityEditor.Animations.AnimatorStateMachine lRootSubStateMachine = null;

            // If we find the sm with our name, remove it
            for (int i = 0; i < lRootStateMachine.stateMachines.Length; i++)
            {
                // Look for a sm with the matching name
                if (lRootStateMachine.stateMachines[i].stateMachine.name == _EditorAnimatorSMName)
                {
                    lRootSubStateMachine = lRootStateMachine.stateMachines[i].stateMachine;

                    // Allow the user to stop before we remove the sm
                    if (!UnityEditor.EditorUtility.DisplayDialog("Motion Controller", _EditorAnimatorSMName + " already exists. Delete and recreate it?", "Yes", "No"))
                    {
                        return;
                    }

                    // Remove the sm
                    //lRootStateMachine.RemoveStateMachine(lRootStateMachine.stateMachines[i].stateMachine);
                    break;
                }
            }

            UnityEditor.Animations.AnimatorStateMachine lSM_41686 = lRootSubStateMachine;
            if (lSM_41686 != null)
            {
                for (int i = lSM_41686.entryTransitions.Length - 1; i >= 0; i--)
                {
                    lSM_41686.RemoveEntryTransition(lSM_41686.entryTransitions[i]);
                }

                for (int i = lSM_41686.anyStateTransitions.Length - 1; i >= 0; i--)
                {
                    lSM_41686.RemoveAnyStateTransition(lSM_41686.anyStateTransitions[i]);
                }

                for (int i = lSM_41686.states.Length - 1; i >= 0; i--)
                {
                    lSM_41686.RemoveState(lSM_41686.states[i].state);
                }

                for (int i = lSM_41686.stateMachines.Length - 1; i >= 0; i--)
                {
                    lSM_41686.RemoveStateMachine(lSM_41686.stateMachines[i].stateMachine);
                }
            }
            else
            {
                lSM_41686 = lSM_41656.AddStateMachine(_EditorAnimatorSMName, new Vector3(192, 324, 0));
            }

            UnityEditor.Animations.AnimatorState lS_42706 = lSM_41686.AddState("Spell Idle Out", new Vector3(576, 48, 0));
            lS_42706.speed  = 1f;
            lS_42706.motion = m20620;

            UnityEditor.Animations.AnimatorState lS_42708 = lSM_41686.AddState("Stand Idle Out", new Vector3(576, 120, 0));
            lS_42708.speed  = 1f;
            lS_42708.motion = m17212;

            UnityEditor.Animations.AnimatorState lS_41992 = lSM_41686.AddState("Store Spell", new Vector3(312, 120, 0));
            lS_41992.speed  = -1.1f;
            lS_41992.motion = m19754;

            UnityEditor.Animations.AnimatorState lS_41990 = lSM_41686.AddState("Equip Spell", new Vector3(312, 48, 0));
            lS_41990.speed  = 1.1f;
            lS_41990.motion = m19754;

            // Create the transition from the any state. Note that 'AnyState' transitions have to be added to the root
            UnityEditor.Animations.AnimatorStateTransition lT_41758 = lRootStateMachine.AddAnyStateTransition(lS_41990);
            lT_41758.hasExitTime         = false;
            lT_41758.hasFixedDuration    = true;
            lT_41758.exitTime            = 0.9f;
            lT_41758.duration            = 0.1f;
            lT_41758.offset              = 0f;
            lT_41758.mute                = false;
            lT_41758.solo                = false;
            lT_41758.canTransitionToSelf = true;
            lT_41758.interruptionSource  = (UnityEditor.Animations.TransitionInterruptionSource) 0;
            lT_41758.AddCondition(UnityEditor.Animations.AnimatorConditionMode.Equals, 32110f, "L0MotionPhase");

            // Create the transition from the any state. Note that 'AnyState' transitions have to be added to the root
            UnityEditor.Animations.AnimatorStateTransition lT_41760 = lRootStateMachine.AddAnyStateTransition(lS_41992);
            lT_41760.hasExitTime         = false;
            lT_41760.hasFixedDuration    = true;
            lT_41760.exitTime            = 0.9f;
            lT_41760.duration            = 0.2f;
            lT_41760.offset              = 0f;
            lT_41760.mute                = false;
            lT_41760.solo                = false;
            lT_41760.canTransitionToSelf = true;
            lT_41760.interruptionSource  = (UnityEditor.Animations.TransitionInterruptionSource) 0;
            lT_41760.AddCondition(UnityEditor.Animations.AnimatorConditionMode.Equals, 32115f, "L0MotionPhase");

            UnityEditor.Animations.AnimatorStateTransition lT_42710 = lS_41992.AddTransition(lS_42708);
            lT_42710.hasExitTime         = true;
            lT_42710.hasFixedDuration    = true;
            lT_42710.exitTime            = 0.8857439f;
            lT_42710.duration            = 0.1033962f;
            lT_42710.offset              = 1.507076f;
            lT_42710.mute                = false;
            lT_42710.solo                = false;
            lT_42710.canTransitionToSelf = true;
            lT_42710.interruptionSource  = (UnityEditor.Animations.TransitionInterruptionSource) 0;

            UnityEditor.Animations.AnimatorStateTransition lT_42712 = lS_41990.AddTransition(lS_42706);
            lT_42712.hasExitTime         = true;
            lT_42712.hasFixedDuration    = true;
            lT_42712.exitTime            = 0.5385581f;
            lT_42712.duration            = 0.3215042f;
            lT_42712.offset              = 0f;
            lT_42712.mute                = false;
            lT_42712.solo                = false;
            lT_42712.canTransitionToSelf = true;
            lT_42712.interruptionSource  = (UnityEditor.Animations.TransitionInterruptionSource) 0;
        }
            public override void OnInspectorGUI()
            {
                obj.Update();

                animatorValidated = false;

                Animator animComponent = (obj.targetObject as MLPASAnimatorSFXController).GetComponent <Animator>();

                if (animComponent != null)
                {
                    string assetPath = AssetDatabase.GetAssetPath(animComponent.runtimeAnimatorController);

                    UnityEditor.Animations.AnimatorController newAnim = AssetDatabase.LoadAssetAtPath <UnityEditor.Animations.AnimatorController>(assetPath);

                    if (anim != newAnim)
                    {
                        anim = newAnim;
                    }
                }

                if (anim != null)
                {
                    animatorValidated = true;
                }

                if (!animatorValidated)
                {
                    EditorGUILayout.HelpBox("This Component needs to be placed next to an Animator Component", MessageType.Error);
                    return;
                }

                GUILayout.BeginVertical(EditorStyles.helpBox);

                List <MLPASAnimatorSFX> validatedAnimatorSfxes = new List <MLPASAnimatorSFX>();

                foreach (var i in anim.GetBehaviours <MLPASAnimatorSFX>())
                {
                    if (!validatedAnimatorSfxes.Contains(i))
                    {
                        validatedAnimatorSfxes.Add(i);
                    }
                }

                Color color_default = GUI.backgroundColor;


                GUIStyle itemStyle = new GUIStyle(GUI.skin.box);           //make a new GUIStyle

                itemStyle.alignment         = TextAnchor.MiddleLeft;       //align text to the left
                itemStyle.active.background = itemStyle.normal.background; //gets rid of button click background style.
                itemStyle.margin            = new RectOffset(0, 0, 0, 0);  //removes the space between items (previously there was a small gap between GUI which made it harder to select a desired item)
                itemStyle.font               = EditorStyles.miniFont;
                itemStyle.fontSize           = 10;
                itemStyle.fixedWidth         = 0;
                itemStyle.stretchWidth       = true;
                itemStyle.wordWrap           = true;
                itemStyle.richText           = true;
                itemStyle.normal.textColor   = EditorGUIUtility.isProSkin ? new Color(0.8f, 0.8f, 0.8f) : Color.black;
                itemStyle.hover.textColor    = itemStyle.normal.textColor;
                itemStyle.active.textColor   = itemStyle.normal.textColor;
                itemStyle.focused.textColor  = itemStyle.normal.textColor;
                itemStyle.normal.background  = uiBack;
                itemStyle.hover.background   = uiBack;
                itemStyle.active.background  = uiBack;
                itemStyle.focused.background = uiBack;

                if (validatedAnimatorSfxes.Count > 0)
                {
                    GUILayout.BeginVertical(EditorStyles.helpBox);

                    for (int i = 0; i < validatedAnimatorSfxes.Count; i++)
                    {
                        // Color font_default = GUI.color;
                        GUI.backgroundColor = (selectedIndexStateM == i) ? color_selected : new Color(1, 1, 1, 0.25f);
                        if (EditorGUIUtility.isProSkin)
                        {
                            GUI.backgroundColor = (selectedIndexStateM == i) ? colorPro_selected : new Color(0.25f, 0.25f, 0.25f, 0.25f);
                        }
                        //  GUI.color = (selectedIndex == i) ? font_selected : font_default;

                        string layerName = "";

                        for (int iL = 0; iL < anim.layers.Length; iL++)
                        {
                            if (iL == validatedAnimatorSfxes[i].transitionLayer)
                            {
                                layerName = anim.layers[iL].name;
                            }
                        }

                        string buttonName = "L: " + layerName + " | " + (validatedAnimatorSfxes[i].currentState != null ? "S: " + validatedAnimatorSfxes[i].currentState.name : "SM: " + validatedAnimatorSfxes[i].currentStateMachine.name);


                        if (GUILayout.Button(buttonName, itemStyle))
                        {
                            selectedIndexStateM = i;

                            if (prevSelectedIndexStateM != selectedIndexStateM)
                            {
                                Repaint();
                                prevSelectedIndexStateM = selectedIndexStateM;
                                EditorGUI.FocusTextInControl(null);
                            }

                            valuesModified = true;
                        }

                        GUI.backgroundColor = color_default; //this is to avoid affecting other GUIs outside of the list
                    }



                    GUILayout.EndVertical();

                    if (EditorApplication.isPlaying)
                    {
                        GUI.enabled = false;
                    }



                    EditorGUILayout.Space();

                    MLPASAnimatorSFXController.ValuesOverride newValue = null;

                    if (!ContainsStateEditor(validatedAnimatorSfxes[selectedIndexStateM], out newValue))
                    {
                        newValue = new MLPASAnimatorSFXController.ValuesOverride();

                        UnityEditor.Animations.StateMachineBehaviourContext[] context = UnityEditor.Animations.AnimatorController.FindStateMachineBehaviourContext(validatedAnimatorSfxes[selectedIndexStateM]);
                        UnityEditor.Animations.AnimatorState        cState            = (context[0].animatorObject as UnityEditor.Animations.AnimatorState);
                        UnityEditor.Animations.AnimatorStateMachine cStateMachine     = (context[0].animatorObject as UnityEditor.Animations.AnimatorStateMachine);

                        string stateName = cState != null ? cState.name : cStateMachine.name;
                        int    layer     = context[0].layerIndex;

                        newValue.layer     = layer;
                        newValue.stateName = stateName;
                        (obj.targetObject as MLPASAnimatorSFXController).newValues.Add(newValue);
                    }


                    BoolField("Use Different Play Position", ref newValue.useDifferentPlayPosition);

                    if (newValue.useDifferentPlayPosition)
                    {
                        TransformField("Play Position Transform", ref newValue.playPosition);
                        BoolField("Follow Play Position", ref newValue.followPosition);
                    }


                    GUILayout.EndVertical();

                    if (!EditorApplication.isPlaying)
                    {
                        EditorGUILayout.Space();

                        EditorGUILayout.LabelField("Custom Play Methods", EditorStyles.boldLabel);

                        EditorGUILayout.BeginVertical(EditorStyles.helpBox);

                        customPlayMethodObj = EditorGUILayout.ObjectField(new GUIContent("Target GameObject", ""), customPlayMethodObj, typeof(GameObject), true) as GameObject;
                        if (customPlayMethodObj != null && EditorUtility.IsPersistent(customPlayMethodObj))
                        {
                            customPlayMethodObj = null;
                        }
                        List <MLPASAnimatorSFXController.InspectorDelegate> inspectorDelegates = new List <MLPASAnimatorSFXController.InspectorDelegate>();



                        if (customPlayMethodObj != null)
                        {
                            Component[] components = customPlayMethodObj.GetComponents <Component>();

                            foreach (var item in components)
                            {
                                System.Reflection.MethodInfo[] methods = item.GetType().GetMethods();


                                for (int i = 0; i < methods.Length; i++)
                                {
                                    System.Reflection.ParameterInfo[] parameters = methods[i].GetParameters();

                                    for (int i2 = 0; i2 < parameters.Length; i2++)
                                    {
                                        if (parameters[i2].ParameterType == typeof(MLPASACustomPlayMethodParameters))
                                        {
                                            MLPASAnimatorSFXController.InspectorDelegate del = new MLPASAnimatorSFXController.InspectorDelegate();
                                            del.methodName = methods[i].Name;
                                            del.target     = item;
                                            inspectorDelegates.Add(del);
                                            break;
                                        }
                                    }
                                }
                            }


                            string[] methodNames = new string[inspectorDelegates.Count];


                            for (int i = 0; i < inspectorDelegates.Count; i++)
                            {
                                methodNames[i] = i.ToString() + " - " + inspectorDelegates[i].methodName + " (MLPASACustomPlayMethodParameters)";
                            }

                            if (inspectorDelegates.Count > 0)
                            {
                                playMethodIndex = EditorGUILayout.Popup(playMethodIndex, methodNames);

                                bool alreadyExists = false;

                                foreach (var item in (obj.targetObject as MLPASAnimatorSFXController).inspectorDelegates)
                                {
                                    if (item.methodName == inspectorDelegates[playMethodIndex].methodName)
                                    {
                                        alreadyExists = true;
                                        break;
                                    }
                                }

                                bool prevGuiEnabled = GUI.enabled;
                                GUI.enabled = !alreadyExists;
                                Color prevBackground = GUI.backgroundColor;
                                GUI.backgroundColor = new Color(0.35f, 0.8f, 0.95f);
                                if (GUILayout.Button(alreadyExists ? inspectorDelegates[playMethodIndex].methodName + " Already Exists" : "Add Custom Play Method", EditorStyles.miniButton))
                                {
                                    if ((obj.targetObject as MLPASAnimatorSFXController).inspectorDelegates == null)
                                    {
                                        (obj.targetObject as MLPASAnimatorSFXController).inspectorDelegates = new List <MLPASAnimatorSFXController.InspectorDelegate>();
                                    }

                                    (obj.targetObject as MLPASAnimatorSFXController).inspectorDelegates.Add(inspectorDelegates[playMethodIndex]);

                                    valuesModified = true;
                                }
                                GUI.backgroundColor = prevBackground;
                                GUI.enabled         = prevGuiEnabled;
                            }
                            else
                            {
                                playMethodIndex = 0;

                                EditorGUILayout.LabelField("No methods found", EditorStyles.miniLabel);
                                bool prevGuiEnabled = GUI.enabled;
                                GUI.enabled = false;
                                Color prevBackground = GUI.backgroundColor;
                                GUI.backgroundColor = new Color(0.35f, 0.8f, 0.95f);
                                GUILayout.Button("Select Another GameObject", EditorStyles.miniButton);
                                GUI.backgroundColor = prevBackground;
                                GUI.enabled         = prevGuiEnabled;
                            }
                        }
                        else
                        {
                            bool prevGuiEnabled = GUI.enabled;
                            GUI.enabled = false;
                            Color prevBackground = GUI.backgroundColor;
                            GUI.backgroundColor = new Color(0.35f, 0.8f, 0.95f);
                            GUILayout.Button("Select a GameObject", EditorStyles.miniButton);
                            GUI.backgroundColor = prevBackground;
                            GUI.enabled         = prevGuiEnabled;
                        }

                        EditorGUILayout.EndVertical();

                        for (int i = 0; i < (obj.targetObject as MLPASAnimatorSFXController).inspectorDelegates.Count; i++)
                        {
                            EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                            bool prevGuiEnabled = GUI.enabled;
                            GUI.enabled = false;
                            if ((obj.targetObject as MLPASAnimatorSFXController).inspectorDelegates[i].target == null)
                            {
                                EditorGUILayout.ObjectField("Target GameObject", null, typeof(GameObject), true);
                            }
                            else
                            {
                                EditorGUILayout.ObjectField("Target GameObject", (obj.targetObject as MLPASAnimatorSFXController).inspectorDelegates[i].target.gameObject, typeof(GameObject), true);
                            }

                            if (!(obj.targetObject as MLPASAnimatorSFXController).inspectorDelegates[i].removed)
                            {
                                EditorGUILayout.Popup(0, new string[] { (obj.targetObject as MLPASAnimatorSFXController).inspectorDelegates[i].methodName + " (MLPASACustomPlayMethodParameters)" });
                            }
                            else
                            {
                                EditorGUILayout.Popup(0, new string[] { (obj.targetObject as MLPASAnimatorSFXController).inspectorDelegates[i].methodName + " | MISSING" });
                            }

                            GUI.enabled = prevGuiEnabled;

                            Color prevBackground = GUI.backgroundColor;
                            GUI.backgroundColor = new Color(1f, 0.35f, 0.38f);
                            if (GUILayout.Button("Remove Play Method", EditorStyles.miniButton))
                            {
                                (obj.targetObject as MLPASAnimatorSFXController).inspectorDelegates.RemoveAt(i);
                                valuesModified = true;
                            }
                            GUI.backgroundColor = prevBackground;

                            EditorGUILayout.EndVertical();
                        }
                    }


                    if (valuesModified && !dirty)
                    {
                        dirty          = true;
                        valuesModified = false;
                        if (!EditorApplication.isPlaying)
                        {
                            SetObjectDirty((obj.targetObject as MLPASAnimatorSFXController));
                        }
                    }
                }
                else
                {
                    EditorGUILayout.HelpBox("The 'Animator' Next to this 'MLPASAnimatorSFXController' doesn't have any 'MLPASAnimatorSFX' State Machine Behaviour", MessageType.Warning);
                    GUILayout.EndVertical();

                    return;
                }



                GUI.enabled = true;


                if (EditorApplication.isPlaying)
                {
                    EditorGUILayout.Space();

                    bool nullMethods = true;
                    EditorGUILayout.LabelField("Registered Custom Play Methods", EditorStyles.boldLabel);

                    foreach (var item in (obj.targetObject as MLPASAnimatorSFXController).customPlayMethods)
                    {
                        if (item.Value != null)
                        {
                            EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                            GUI.enabled = false;
                            Component comp = ((item.Value.Target) as Component);
                            if (comp != null)
                            {
                                nullMethods = false;
                            }

                            EditorGUILayout.ObjectField("Target GameObject", comp != null ? comp.gameObject : null, typeof(GameObject), true);

                            if (comp != null)
                            {
                                EditorGUILayout.Popup(0, new string[] { item.Value.Method.Name + " (MLPASACustomPlayMethodParameters)" });
                            }
                            else
                            {
                                EditorGUILayout.Popup(0, new string[] { item.Value.Method.Name + " | MISSING" });
                            }
                            GUI.enabled = true;
                            EditorGUILayout.EndVertical();
                        }
                    }

                    if (nullMethods)
                    {
                        EditorGUILayout.LabelField("No methods found");
                    }
                }

                obj.ApplyModifiedProperties();
            }
예제 #27
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_N1556694 = MotionControllerMotion.EditorFindSSM(lLayerStateMachine, "BasicInteraction-SM");
            if (lSSM_N1556694 == null)
            {
                lSSM_N1556694 = lLayerStateMachine.AddStateMachine("BasicInteraction-SM", new Vector3(408, -960, 0));
            }

            UnityEditor.Animations.AnimatorState lState_N1565974 = MotionControllerMotion.EditorFindState(lSSM_N1556694, "Idle_GrabHighFront");
            if (lState_N1565974 == null)
            {
                lState_N1565974 = lSSM_N1556694.AddState("Idle_GrabHighFront", new Vector3(337, 54, 0));
            }
            lState_N1565974.speed  = 1.5f;
            lState_N1565974.mirror = false;
            lState_N1565974.tag    = "";
            lState_N1565974.motion = MotionControllerMotion.EditorFindAnimationClip("Assets/ootii/MotionController/Content/Animations/Humanoid/Interacting/Unity_IdleGrab_FrontHigh.fbx", "Idle_GrabHighFront");

            UnityEditor.Animations.AnimatorState lState_N1566382 = MotionControllerMotion.EditorFindState(lSSM_N1556694, "Idle_PickUp");
            if (lState_N1566382 == null)
            {
                lState_N1566382 = lSSM_N1556694.AddState("Idle_PickUp", new Vector3(336, 168, 0));
            }
            lState_N1566382.speed  = 1.5f;
            lState_N1566382.mirror = false;
            lState_N1566382.tag    = "";
            lState_N1566382.motion = MotionControllerMotion.EditorFindAnimationClip("Assets/ootii/MotionController/Content/Animations/Humanoid/Interacting/unity_IdleGrab_LowFront.fbx", "Idle_PickUp");

            UnityEditor.Animations.AnimatorState lState_N1567060 = MotionControllerMotion.EditorFindState(lSSM_N1556694, "Idle_PushButton");
            if (lState_N1567060 == null)
            {
                lState_N1567060 = lSSM_N1556694.AddState("Idle_PushButton", new Vector3(336, -48, 0));
            }
            lState_N1567060.speed  = 1.5f;
            lState_N1567060.mirror = false;
            lState_N1567060.tag    = "";
            lState_N1567060.motion = MotionControllerMotion.EditorFindAnimationClip("Assets/ootii/MotionController/Content/Animations/Humanoid/Interacting/unity_IdleGrab_Neutral.fbx", "Idle_PushButton");

            UnityEditor.Animations.AnimatorState lState_N1568354 = MotionControllerMotion.EditorFindState(lSSM_N1556694, "IdlePose");
            if (lState_N1568354 == null)
            {
                lState_N1568354 = lSSM_N1556694.AddState("IdlePose", new Vector3(600, 48, 0));
            }
            lState_N1568354.speed  = 1f;
            lState_N1568354.mirror = false;
            lState_N1568354.tag    = "Exit";
            lState_N1568354.motion = MotionControllerMotion.EditorFindAnimationClip("Assets/ootii/MotionController/Content/Animations/Humanoid/Idling/unity_Idle_IdleToIdlesR.fbx", "IdlePose");

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

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

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

            UnityEditor.Animations.AnimatorStateTransition lTransition_N1569370 = MotionControllerMotion.EditorFindTransition(lState_N1565974, lState_N1568354, 0);
            if (lTransition_N1569370 == null)
            {
                lTransition_N1569370 = lState_N1565974.AddTransition(lState_N1568354);
            }
            lTransition_N1569370.isExit              = false;
            lTransition_N1569370.hasExitTime         = true;
            lTransition_N1569370.hasFixedDuration    = true;
            lTransition_N1569370.exitTime            = 0.9285715f;
            lTransition_N1569370.duration            = 0.25f;
            lTransition_N1569370.offset              = 0f;
            lTransition_N1569370.mute                = false;
            lTransition_N1569370.solo                = false;
            lTransition_N1569370.canTransitionToSelf = true;
            lTransition_N1569370.interruptionSource  = (UnityEditor.Animations.TransitionInterruptionSource) 0;
            for (int i = lTransition_N1569370.conditions.Length - 1; i >= 0; i--)
            {
                lTransition_N1569370.RemoveCondition(lTransition_N1569370.conditions[i]);
            }

            UnityEditor.Animations.AnimatorStateTransition lTransition_N1569788 = MotionControllerMotion.EditorFindTransition(lState_N1566382, lState_N1568354, 0);
            if (lTransition_N1569788 == null)
            {
                lTransition_N1569788 = lState_N1566382.AddTransition(lState_N1568354);
            }
            lTransition_N1569788.isExit              = false;
            lTransition_N1569788.hasExitTime         = true;
            lTransition_N1569788.hasFixedDuration    = true;
            lTransition_N1569788.exitTime            = 0.90625f;
            lTransition_N1569788.duration            = 0.25f;
            lTransition_N1569788.offset              = 0f;
            lTransition_N1569788.mute                = false;
            lTransition_N1569788.solo                = false;
            lTransition_N1569788.canTransitionToSelf = true;
            lTransition_N1569788.interruptionSource  = (UnityEditor.Animations.TransitionInterruptionSource) 0;
            for (int i = lTransition_N1569788.conditions.Length - 1; i >= 0; i--)
            {
                lTransition_N1569788.RemoveCondition(lTransition_N1569788.conditions[i]);
            }

            UnityEditor.Animations.AnimatorStateTransition lTransition_N1569000 = MotionControllerMotion.EditorFindTransition(lState_N1567060, lState_N1568354, 0);
            if (lTransition_N1569000 == null)
            {
                lTransition_N1569000 = lState_N1567060.AddTransition(lState_N1568354);
            }
            lTransition_N1569000.isExit              = false;
            lTransition_N1569000.hasExitTime         = true;
            lTransition_N1569000.hasFixedDuration    = true;
            lTransition_N1569000.exitTime            = 0.7673402f;
            lTransition_N1569000.duration            = 0.2499998f;
            lTransition_N1569000.offset              = 0f;
            lTransition_N1569000.mute                = false;
            lTransition_N1569000.solo                = false;
            lTransition_N1569000.canTransitionToSelf = true;
            lTransition_N1569000.interruptionSource  = (UnityEditor.Animations.TransitionInterruptionSource) 0;
            for (int i = lTransition_N1569000.conditions.Length - 1; i >= 0; i--)
            {
                lTransition_N1569000.RemoveCondition(lTransition_N1569000.conditions[i]);
            }


            // Run any post processing after creating the state machine
            OnStateMachineCreated();
        }
예제 #28
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_N237494 = MotionControllerMotion.EditorFindSSM(lLayerStateMachine, "BasicDeath-SM");
            if (lSSM_N237494 == null)
            {
                lSSM_N237494 = lLayerStateMachine.AddStateMachine("BasicDeath-SM", new Vector3(192, -912, 0));
            }

            UnityEditor.Animations.AnimatorState lState_N247470 = MotionControllerMotion.EditorFindState(lSSM_N237494, "Unarmed Death 0");
            if (lState_N247470 == null)
            {
                lState_N247470 = lSSM_N237494.AddState("Unarmed Death 0", new Vector3(324, -72, 0));
            }
            lState_N247470.speed  = 1.5f;
            lState_N247470.mirror = false;
            lState_N247470.tag    = "";
            lState_N247470.motion = MotionControllerMotion.EditorFindAnimationClip("Assets/ootii/Assets/MotionController/Content/Animations/Humanoid/Utilities/Utilities_01.fbx", "DeathBackward");

            UnityEditor.Animations.AnimatorState lState_N247472 = MotionControllerMotion.EditorFindState(lSSM_N237494, "Unarmed Death 180");
            if (lState_N247472 == null)
            {
                lState_N247472 = lSSM_N237494.AddState("Unarmed Death 180", new Vector3(324, -24, 0));
            }
            lState_N247472.speed  = 1.8f;
            lState_N247472.mirror = false;
            lState_N247472.tag    = "";
            lState_N247472.motion = MotionControllerMotion.EditorFindAnimationClip("Assets/ootii/Assets/MotionController/Content/Animations/Humanoid/Utilities/Utilities_01.fbx", "DeathForward");

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

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

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

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

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

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

            // Run any post processing after creating the state machine
            OnStateMachineCreated();
        }
예제 #29
0
        /// <summary>
        /// Creates the preview state machine.
        /// </summary>
        /// <param name="motion">Motion.</param>
        private void CreatePreviewStateMachine(Motion motion)
        {
            if (this.Animator == null)
                                return;

                        //Debug.Log ("CreateStateMachine");

                        if (_previewAnimatorController == null) {
                                _previewAnimatorController = new UnityEditor.Animations.AnimatorController ();
                                _previewAnimatorController.AddLayer ("previewLayer");
                                _previewAnimatorController.hideFlags = HideFlags.DontSave;

                                _previewStateMachine = _previewAnimatorController.layers [0].stateMachine;
                                CreateParameters (motion);

                                _previewState = _previewStateMachine.AddState ("previewState");

                                _previewState.motion = motion;
                                _previewState.iKOnFeet = this.IKOnFeet;
                                _previewState.hideFlags = HideFlags.DontSave;

                                UnityEditor.Animations.AnimatorController.SetAnimatorController (this.Animator, _previewAnimatorController);
                                //Debug.Log ("Setting avatarPreview.Animator " + this.Animator.name + " to temp controller");
                        }

            //			if (AnimatorController.GetEffectiveAnimatorController (this.Animator) != this._previewAnimatorController) {
            //				AnimatorController.SetAnimatorController (this.Animator, this._previewAnimatorController);
            //
            //				Debug.Log ("Getting Effective Animator and set avatarPreview.Animator " + this.Animator.name + " to temp controller");
            //			}
        }
예제 #30
0
        /// <summary>
        /// Creates the animator substate machine for this motion.
        /// </summary>
        protected override void CreateStateMachine()
        {
            // Grab the root sm for the layer
            UnityEditor.Animations.AnimatorStateMachine lRootStateMachine    = _EditorAnimatorController.layers[mMotionLayer.AnimatorLayerIndex].stateMachine;
            UnityEditor.Animations.AnimatorStateMachine lSM_24530            = _EditorAnimatorController.layers[mMotionLayer.AnimatorLayerIndex].stateMachine;
            UnityEditor.Animations.AnimatorStateMachine lRootSubStateMachine = null;

            // If we find the sm with our name, remove it
            for (int i = 0; i < lRootStateMachine.stateMachines.Length; i++)
            {
                // Look for a sm with the matching name
                if (lRootStateMachine.stateMachines[i].stateMachine.name == _EditorAnimatorSMName)
                {
                    lRootSubStateMachine = lRootStateMachine.stateMachines[i].stateMachine;

                    // Allow the user to stop before we remove the sm
                    if (!UnityEditor.EditorUtility.DisplayDialog("Motion Controller", _EditorAnimatorSMName + " already exists. Delete and recreate it?", "Yes", "No"))
                    {
                        return;
                    }

                    // Remove the sm
                    //lRootStateMachine.RemoveStateMachine(lRootStateMachine.stateMachines[i].stateMachine);
                    break;
                }
            }

            UnityEditor.Animations.AnimatorStateMachine lSM_24570 = lRootSubStateMachine;
            if (lSM_24570 != null)
            {
                for (int i = lSM_24570.entryTransitions.Length - 1; i >= 0; i--)
                {
                    lSM_24570.RemoveEntryTransition(lSM_24570.entryTransitions[i]);
                }

                for (int i = lSM_24570.anyStateTransitions.Length - 1; i >= 0; i--)
                {
                    lSM_24570.RemoveAnyStateTransition(lSM_24570.anyStateTransitions[i]);
                }

                for (int i = lSM_24570.states.Length - 1; i >= 0; i--)
                {
                    lSM_24570.RemoveState(lSM_24570.states[i].state);
                }

                for (int i = lSM_24570.stateMachines.Length - 1; i >= 0; i--)
                {
                    lSM_24570.RemoveStateMachine(lSM_24570.stateMachines[i].stateMachine);
                }
            }
            else
            {
                lSM_24570 = lSM_24530.AddStateMachine(_EditorAnimatorSMName, new Vector3(408, -756, 0));
            }

            UnityEditor.Animations.AnimatorState lS_25730 = lSM_24570.AddState("IdlePose", new Vector3(600, 120, 0));
            lS_25730.speed  = 1f;
            lS_25730.motion = m14552;

            UnityEditor.Animations.AnimatorState lS_24896 = lSM_24570.AddState("Move Tree", new Vector3(312, 120, 0));
            lS_24896.speed = 1f;

            UnityEditor.Animations.BlendTree lM_24106 = CreateBlendTree("Move Blend Tree", _EditorAnimatorController, mMotionLayer.AnimatorLayerIndex);
            lM_24106.blendType       = UnityEditor.Animations.BlendTreeType.Simple1D;
            lM_24106.blendParameter  = "InputMagnitude";
            lM_24106.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_24106.useAutomaticThresholds = false;
#endif
            lM_24106.AddChild(m14552, 0f);

            UnityEditor.Animations.BlendTree lM_24146 = CreateBlendTree("WalkTree", _EditorAnimatorController, mMotionLayer.AnimatorLayerIndex);
            lM_24146.blendType       = UnityEditor.Animations.BlendTreeType.SimpleDirectional2D;
            lM_24146.blendParameter  = "InputX";
            lM_24146.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_24146.useAutomaticThresholds = true;
#endif
            lM_24146.AddChild(m20884, new Vector2(0f, 0.35f));
            UnityEditor.Animations.ChildMotion[] lM_24146_0_Children = lM_24146.children;
            lM_24146_0_Children[lM_24146_0_Children.Length - 1].mirror    = false;
            lM_24146_0_Children[lM_24146_0_Children.Length - 1].timeScale = 1.1f;
            lM_24146.children = lM_24146_0_Children;

            lM_24146.AddChild(m20104, new Vector2(0.35f, 0.35f));
            UnityEditor.Animations.ChildMotion[] lM_24146_1_Children = lM_24146.children;
            lM_24146_1_Children[lM_24146_1_Children.Length - 1].mirror    = false;
            lM_24146_1_Children[lM_24146_1_Children.Length - 1].timeScale = 1.2f;
            lM_24146.children = lM_24146_1_Children;

            lM_24146.AddChild(m20102, new Vector2(-0.35f, 0.35f));
            UnityEditor.Animations.ChildMotion[] lM_24146_2_Children = lM_24146.children;
            lM_24146_2_Children[lM_24146_2_Children.Length - 1].mirror    = false;
            lM_24146_2_Children[lM_24146_2_Children.Length - 1].timeScale = 1.2f;
            lM_24146.children = lM_24146_2_Children;

            lM_24146.AddChild(m20106, new Vector2(-0.35f, 0f));
            UnityEditor.Animations.ChildMotion[] lM_24146_3_Children = lM_24146.children;
            lM_24146_3_Children[lM_24146_3_Children.Length - 1].mirror    = false;
            lM_24146_3_Children[lM_24146_3_Children.Length - 1].timeScale = 1.2f;
            lM_24146.children = lM_24146_3_Children;

            lM_24146.AddChild(m20108, new Vector2(0.35f, 0f));
            UnityEditor.Animations.ChildMotion[] lM_24146_4_Children = lM_24146.children;
            lM_24146_4_Children[lM_24146_4_Children.Length - 1].mirror    = false;
            lM_24146_4_Children[lM_24146_4_Children.Length - 1].timeScale = 1.2f;
            lM_24146.children = lM_24146_4_Children;

            lM_24146.AddChild(m21194, new Vector2(-0.35f, -0.35f));
            UnityEditor.Animations.ChildMotion[] lM_24146_5_Children = lM_24146.children;
            lM_24146_5_Children[lM_24146_5_Children.Length - 1].mirror    = false;
            lM_24146_5_Children[lM_24146_5_Children.Length - 1].timeScale = 1.1f;
            lM_24146.children = lM_24146_5_Children;

            lM_24146.AddChild(m21196, new Vector2(0.35f, -0.35f));
            UnityEditor.Animations.ChildMotion[] lM_24146_6_Children = lM_24146.children;
            lM_24146_6_Children[lM_24146_6_Children.Length - 1].mirror    = false;
            lM_24146_6_Children[lM_24146_6_Children.Length - 1].timeScale = 1.1f;
            lM_24146.children = lM_24146_6_Children;

            lM_24146.AddChild(m24326, new Vector2(0f, -0.35f));
            UnityEditor.Animations.ChildMotion[] lM_24146_7_Children = lM_24146.children;
            lM_24146_7_Children[lM_24146_7_Children.Length - 1].mirror    = false;
            lM_24146_7_Children[lM_24146_7_Children.Length - 1].timeScale = 1f;
            lM_24146.children = lM_24146_7_Children;

            lM_24106.AddChild(lM_24146, 0.5f);

            UnityEditor.Animations.BlendTree lM_24116 = CreateBlendTree("RunTree", _EditorAnimatorController, mMotionLayer.AnimatorLayerIndex);
            lM_24116.blendType       = UnityEditor.Animations.BlendTreeType.SimpleDirectional2D;
            lM_24116.blendParameter  = "InputX";
            lM_24116.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_24116.useAutomaticThresholds = true;
#endif
            lM_24116.AddChild(m14502, new Vector2(0f, 0.7f));
            UnityEditor.Animations.ChildMotion[] lM_24116_0_Children = lM_24116.children;
            lM_24116_0_Children[lM_24116_0_Children.Length - 1].mirror    = false;
            lM_24116_0_Children[lM_24116_0_Children.Length - 1].timeScale = 1f;
            lM_24116.children = lM_24116_0_Children;

            lM_24116.AddChild(m22442, new Vector2(0.7f, 0.7f));
            UnityEditor.Animations.ChildMotion[] lM_24116_1_Children = lM_24116.children;
            lM_24116_1_Children[lM_24116_1_Children.Length - 1].mirror    = false;
            lM_24116_1_Children[lM_24116_1_Children.Length - 1].timeScale = 1.1f;
            lM_24116.children = lM_24116_1_Children;

            lM_24116.AddChild(m22440, new Vector2(-0.7f, 0.7f));
            UnityEditor.Animations.ChildMotion[] lM_24116_2_Children = lM_24116.children;
            lM_24116_2_Children[lM_24116_2_Children.Length - 1].mirror    = false;
            lM_24116_2_Children[lM_24116_2_Children.Length - 1].timeScale = 1.1f;
            lM_24116.children = lM_24116_2_Children;

            lM_24116.AddChild(m22444, new Vector2(-0.7f, 0f));
            UnityEditor.Animations.ChildMotion[] lM_24116_3_Children = lM_24116.children;
            lM_24116_3_Children[lM_24116_3_Children.Length - 1].mirror    = false;
            lM_24116_3_Children[lM_24116_3_Children.Length - 1].timeScale = 1f;
            lM_24116.children = lM_24116_3_Children;

            lM_24116.AddChild(m22446, new Vector2(0.7f, 0f));
            UnityEditor.Animations.ChildMotion[] lM_24116_4_Children = lM_24116.children;
            lM_24116_4_Children[lM_24116_4_Children.Length - 1].mirror    = false;
            lM_24116_4_Children[lM_24116_4_Children.Length - 1].timeScale = 1f;
            lM_24116.children = lM_24116_4_Children;

            lM_24116.AddChild(m22436, new Vector2(-0.7f, -0.7f));
            UnityEditor.Animations.ChildMotion[] lM_24116_5_Children = lM_24116.children;
            lM_24116_5_Children[lM_24116_5_Children.Length - 1].mirror    = false;
            lM_24116_5_Children[lM_24116_5_Children.Length - 1].timeScale = 1.1f;
            lM_24116.children = lM_24116_5_Children;

            lM_24116.AddChild(m22438, new Vector2(0.7f, -0.7f));
            UnityEditor.Animations.ChildMotion[] lM_24116_6_Children = lM_24116.children;
            lM_24116_6_Children[lM_24116_6_Children.Length - 1].mirror    = false;
            lM_24116_6_Children[lM_24116_6_Children.Length - 1].timeScale = 1.1f;
            lM_24116.children = lM_24116_6_Children;

            lM_24116.AddChild(m18780, new Vector2(0f, -0.7f));
            UnityEditor.Animations.ChildMotion[] lM_24116_7_Children = lM_24116.children;
            lM_24116_7_Children[lM_24116_7_Children.Length - 1].mirror    = false;
            lM_24116_7_Children[lM_24116_7_Children.Length - 1].timeScale = 1f;
            lM_24116.children = lM_24116_7_Children;

            lM_24106.AddChild(lM_24116, 1f);
            lS_24896.motion = lM_24106;

            // Create the transition from the any state. Note that 'AnyState' transitions have to be added to the root
            UnityEditor.Animations.AnimatorStateTransition lT_24700 = lRootStateMachine.AddAnyStateTransition(lS_24896);
            lT_24700.hasExitTime      = false;
            lT_24700.hasFixedDuration = true;
            lT_24700.exitTime         = 0.9f;
            lT_24700.duration         = 0.2f;
            lT_24700.offset           = 0f;
            lT_24700.mute             = false;
            lT_24700.solo             = false;
            lT_24700.AddCondition(UnityEditor.Animations.AnimatorConditionMode.Equals, 1130f, "L0MotionPhase");

            UnityEditor.Animations.AnimatorStateTransition lT_25732 = lS_25730.AddTransition(lS_24896);
            lT_25732.hasExitTime         = false;
            lT_25732.hasFixedDuration    = true;
            lT_25732.exitTime            = 0f;
            lT_25732.duration            = 0.25f;
            lT_25732.offset              = 0f;
            lT_25732.mute                = false;
            lT_25732.solo                = false;
            lT_25732.canTransitionToSelf = true;
            lT_25732.AddCondition(UnityEditor.Animations.AnimatorConditionMode.Greater, 0.1f, "InputMagnitude");

            UnityEditor.Animations.AnimatorStateTransition lT_25734 = lS_24896.AddTransition(lS_25730);
            lT_25734.hasExitTime         = false;
            lT_25734.hasFixedDuration    = true;
            lT_25734.exitTime            = 1f;
            lT_25734.duration            = 0.2f;
            lT_25734.offset              = 0f;
            lT_25734.mute                = false;
            lT_25734.solo                = false;
            lT_25734.canTransitionToSelf = true;
            lT_25734.AddCondition(UnityEditor.Animations.AnimatorConditionMode.Equals, 1135f, "L0MotionPhase");
            lT_25734.AddCondition(UnityEditor.Animations.AnimatorConditionMode.Equals, 0f, "L0MotionParameter");
        }
예제 #31
0
        /// <summary>
        /// Creates the animator substate machine for this motion.
        /// </summary>
        protected override void CreateStateMachine()
        {
            // Grab the root sm for the layer
            UnityEditor.Animations.AnimatorStateMachine lRootStateMachine    = _EditorAnimatorController.layers[mMotionLayer.AnimatorLayerIndex].stateMachine;
            UnityEditor.Animations.AnimatorStateMachine lSM_34270            = _EditorAnimatorController.layers[mMotionLayer.AnimatorLayerIndex].stateMachine;
            UnityEditor.Animations.AnimatorStateMachine lRootSubStateMachine = null;

            // If we find the sm with our name, remove it
            for (int i = 0; i < lRootStateMachine.stateMachines.Length; i++)
            {
                // Look for a sm with the matching name
                if (lRootStateMachine.stateMachines[i].stateMachine.name == _EditorAnimatorSMName)
                {
                    lRootSubStateMachine = lRootStateMachine.stateMachines[i].stateMachine;

                    // Allow the user to stop before we remove the sm
                    if (!UnityEditor.EditorUtility.DisplayDialog("Motion Controller", _EditorAnimatorSMName + " already exists. Delete and recreate it?", "Yes", "No"))
                    {
                        return;
                    }

                    // Remove the sm
                    //lRootStateMachine.RemoveStateMachine(lRootStateMachine.stateMachines[i].stateMachine);
                    break;
                }
            }

            UnityEditor.Animations.AnimatorStateMachine lSM_35666 = lRootSubStateMachine;
            if (lSM_35666 != null)
            {
                for (int i = lSM_35666.entryTransitions.Length - 1; i >= 0; i--)
                {
                    lSM_35666.RemoveEntryTransition(lSM_35666.entryTransitions[i]);
                }

                for (int i = lSM_35666.anyStateTransitions.Length - 1; i >= 0; i--)
                {
                    lSM_35666.RemoveAnyStateTransition(lSM_35666.anyStateTransitions[i]);
                }

                for (int i = lSM_35666.states.Length - 1; i >= 0; i--)
                {
                    lSM_35666.RemoveState(lSM_35666.states[i].state);
                }

                for (int i = lSM_35666.stateMachines.Length - 1; i >= 0; i--)
                {
                    lSM_35666.RemoveStateMachine(lSM_35666.stateMachines[i].stateMachine);
                }
            }
            else
            {
                lSM_35666 = lSM_34270.AddStateMachine(_EditorAnimatorSMName, new Vector3(192, -480, 0));
            }

            UnityEditor.Animations.AnimatorState lS_35692 = lSM_35666.AddState("EmptyPose", new Vector3(312, 84, 0));
            lS_35692.speed = 1f;

            // Create the transition from the any state. Note that 'AnyState' transitions have to be added to the root
            UnityEditor.Animations.AnimatorStateTransition lT_35676 = lRootStateMachine.AddAnyStateTransition(lS_35692);
            lT_35676.hasExitTime         = false;
            lT_35676.hasFixedDuration    = true;
            lT_35676.exitTime            = 0.75f;
            lT_35676.duration            = 0.15f;
            lT_35676.offset              = 0f;
            lT_35676.mute                = false;
            lT_35676.solo                = false;
            lT_35676.canTransitionToSelf = false;
            lT_35676.orderedInterruption = false;
            lT_35676.interruptionSource  = (UnityEditor.Animations.TransitionInterruptionSource) 2;
            lT_35676.AddCondition(UnityEditor.Animations.AnimatorConditionMode.Equals, 3010f, "L" + mMotionLayer._AnimatorLayerIndex + "MotionPhase");
            lT_35676.AddCondition(UnityEditor.Animations.AnimatorConditionMode.Equals, 0f, "L" + mMotionLayer._AnimatorLayerIndex + "MotionForm");
            lT_35676.AddCondition(UnityEditor.Animations.AnimatorConditionMode.Equals, 0f, "L" + mMotionLayer._AnimatorLayerIndex + "MotionParameter");

            // Create the transition from the any state. Note that 'AnyState' transitions have to be added to the root
            UnityEditor.Animations.AnimatorStateTransition lT_35678 = lRootStateMachine.AddAnyStateTransition(lS_35692);
            lT_35678.hasExitTime         = false;
            lT_35678.hasFixedDuration    = true;
            lT_35678.exitTime            = 0.75f;
            lT_35678.duration            = 0f;
            lT_35678.offset              = 0f;
            lT_35678.mute                = false;
            lT_35678.solo                = false;
            lT_35678.canTransitionToSelf = false;
            lT_35678.orderedInterruption = false;
            lT_35678.interruptionSource  = (UnityEditor.Animations.TransitionInterruptionSource) 2;
            lT_35678.AddCondition(UnityEditor.Animations.AnimatorConditionMode.Equals, 3010f, "L" + mMotionLayer._AnimatorLayerIndex + "MotionPhase");
            lT_35678.AddCondition(UnityEditor.Animations.AnimatorConditionMode.Equals, 0f, "L" + mMotionLayer._AnimatorLayerIndex + "MotionForm");
            lT_35678.AddCondition(UnityEditor.Animations.AnimatorConditionMode.Equals, 1f, "L" + mMotionLayer._AnimatorLayerIndex + "MotionParameter");
        }
예제 #32
0
        /// <summary>
        /// Creates the animator substate machine for this motion.
        /// </summary>
        protected override void CreateStateMachine()
        {
            // Grab the root sm for the layer
            UnityEditor.Animations.AnimatorStateMachine lRootStateMachine    = _EditorAnimatorController.layers[mMotionLayer.AnimatorLayerIndex].stateMachine;
            UnityEditor.Animations.AnimatorStateMachine lSM_32610            = _EditorAnimatorController.layers[mMotionLayer.AnimatorLayerIndex].stateMachine;
            UnityEditor.Animations.AnimatorStateMachine lRootSubStateMachine = null;

            // If we find the sm with our name, remove it
            for (int i = 0; i < lRootStateMachine.stateMachines.Length; i++)
            {
                // Look for a sm with the matching name
                if (lRootStateMachine.stateMachines[i].stateMachine.name == _EditorAnimatorSMName)
                {
                    lRootSubStateMachine = lRootStateMachine.stateMachines[i].stateMachine;

                    // Allow the user to stop before we remove the sm
                    if (!UnityEditor.EditorUtility.DisplayDialog("Motion Controller", _EditorAnimatorSMName + " already exists. Delete and recreate it?", "Yes", "No"))
                    {
                        return;
                    }

                    // Remove the sm
                    //lRootStateMachine.RemoveStateMachine(lRootStateMachine.stateMachines[i].stateMachine);
                    break;
                }
            }

            UnityEditor.Animations.AnimatorStateMachine lSM_33036 = lRootSubStateMachine;
            if (lSM_33036 != null)
            {
                for (int i = lSM_33036.entryTransitions.Length - 1; i >= 0; i--)
                {
                    lSM_33036.RemoveEntryTransition(lSM_33036.entryTransitions[i]);
                }

                for (int i = lSM_33036.anyStateTransitions.Length - 1; i >= 0; i--)
                {
                    lSM_33036.RemoveAnyStateTransition(lSM_33036.anyStateTransitions[i]);
                }

                for (int i = lSM_33036.states.Length - 1; i >= 0; i--)
                {
                    lSM_33036.RemoveState(lSM_33036.states[i].state);
                }

                for (int i = lSM_33036.stateMachines.Length - 1; i >= 0; i--)
                {
                    lSM_33036.RemoveStateMachine(lSM_33036.stateMachines[i].stateMachine);
                }
            }
            else
            {
                lSM_33036 = lSM_32610.AddStateMachine(_EditorAnimatorSMName, new Vector3(408, -420, 0));
            }

            UnityEditor.Animations.AnimatorState lS_34708 = lSM_33036.AddState("IdlePose", new Vector3(840, 204, 0));
            lS_34708.speed  = 1f;
            lS_34708.motion = m17118;

            UnityEditor.Animations.AnimatorState lS_34710 = lSM_33036.AddState("RunJump_RunForward", new Vector3(588, 288, 0));
            lS_34710.speed  = 1f;
            lS_34710.motion = m17050;

            UnityEditor.Animations.AnimatorState lS_34426 = lSM_33036.AddState("RunningJump", new Vector3(324, 204, 0));
            lS_34426.speed  = 1f;
            lS_34426.motion = m22024;

            UnityEditor.Animations.AnimatorState lS_34712 = lSM_33036.AddState("LandToIdle", new Vector3(588, 204, 0));
            lS_34712.speed  = 1f;
            lS_34712.motion = m20978;

            // Create the transition from the any state. Note that 'AnyState' transitions have to be added to the root
            UnityEditor.Animations.AnimatorStateTransition lT_33112 = lRootStateMachine.AddAnyStateTransition(lS_34426);
            lT_33112.hasExitTime         = false;
            lT_33112.hasFixedDuration    = true;
            lT_33112.exitTime            = 0.9f;
            lT_33112.duration            = 0.05f;
            lT_33112.offset              = 0f;
            lT_33112.mute                = false;
            lT_33112.solo                = false;
            lT_33112.canTransitionToSelf = true;
            lT_33112.interruptionSource  = (UnityEditor.Animations.TransitionInterruptionSource) 0;
            lT_33112.AddCondition(UnityEditor.Animations.AnimatorConditionMode.Equals, 27500f, "L0MotionPhase");

            UnityEditor.Animations.AnimatorStateTransition lT_34716 = lS_34426.AddTransition(lS_34710);
            lT_34716.hasExitTime         = false;
            lT_34716.hasFixedDuration    = true;
            lT_34716.exitTime            = 0.8318414f;
            lT_34716.duration            = 0.1f;
            lT_34716.offset              = 0.8475341f;
            lT_34716.mute                = false;
            lT_34716.solo                = false;
            lT_34716.canTransitionToSelf = true;
            lT_34716.interruptionSource  = (UnityEditor.Animations.TransitionInterruptionSource) 0;
            lT_34716.AddCondition(UnityEditor.Animations.AnimatorConditionMode.Equals, 27545f, "L0MotionPhase");

            UnityEditor.Animations.AnimatorStateTransition lT_34718 = lS_34426.AddTransition(lS_34712);
            lT_34718.hasExitTime         = false;
            lT_34718.hasFixedDuration    = true;
            lT_34718.exitTime            = 0.8032071f;
            lT_34718.duration            = 0.1951104f;
            lT_34718.offset              = 0f;
            lT_34718.mute                = false;
            lT_34718.solo                = false;
            lT_34718.canTransitionToSelf = true;
            lT_34718.interruptionSource  = (UnityEditor.Animations.TransitionInterruptionSource) 0;
            lT_34718.AddCondition(UnityEditor.Animations.AnimatorConditionMode.Equals, 27540f, "L0MotionPhase");

            UnityEditor.Animations.AnimatorStateTransition lT_34720 = lS_34712.AddTransition(lS_34708);
            lT_34720.hasExitTime         = true;
            lT_34720.hasFixedDuration    = true;
            lT_34720.exitTime            = 0.6590909f;
            lT_34720.duration            = 0.25f;
            lT_34720.offset              = 0f;
            lT_34720.mute                = false;
            lT_34720.solo                = false;
            lT_34720.canTransitionToSelf = true;
            lT_34720.interruptionSource  = (UnityEditor.Animations.TransitionInterruptionSource) 0;
        }