static int _m_Blend(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);


                UnityEngine.Animation gen_to_be_invoked = (UnityEngine.Animation)translator.FastGetCSObj(L, 1);


                int gen_param_count = LuaAPI.lua_gettop(L);

                if (gen_param_count == 2 && (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TSTRING))
                {
                    string _animation = LuaAPI.lua_tostring(L, 2);

                    gen_to_be_invoked.Blend(_animation);



                    return(0);
                }
                if (gen_param_count == 3 && (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TSTRING) && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 3))
                {
                    string _animation    = LuaAPI.lua_tostring(L, 2);
                    float  _targetWeight = (float)LuaAPI.lua_tonumber(L, 3);

                    gen_to_be_invoked.Blend(_animation, _targetWeight);



                    return(0);
                }
                if (gen_param_count == 4 && (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TSTRING) && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 3) && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 4))
                {
                    string _animation    = LuaAPI.lua_tostring(L, 2);
                    float  _targetWeight = (float)LuaAPI.lua_tonumber(L, 3);
                    float  _fadeLength   = (float)LuaAPI.lua_tonumber(L, 4);

                    gen_to_be_invoked.Blend(_animation, _targetWeight, _fadeLength);



                    return(0);
                }
            } catch (System.Exception gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + gen_e));
            }

            return(LuaAPI.luaL_error(L, "invalid arguments to UnityEngine.Animation.Blend!"));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Apply changes to UnityEngine.Animation component
        /// </summary>
        /// <param name="animationComponent">UnityEngine.Animation to apply changes to</param>
        internal void Apply(UnityEngine.Animation animationComponent)
        {
            foreach (var anim in ActiveAnimNodes)                                             // iterate throw all active AnimNodeSequences
            {
                UnityEngine.AnimationState state = animationComponent[anim.CurrentAnimation]; // access state
                if (state != null)
                {
                    state.speed = anim.Speed;
                    // set parameters
                    state.blendMode = BlendMode;
                    state.wrapMode  = anim.WrapMode;
                    state.layer     = LayerIndex;
                    state.weight    = anim.BlendWeight.Weight;

                    // disable or enable animation
                    if (anim.BlendWeight.Weight == 0)
                    {
                        state.enabled = false;
                    }
                    else
                    {
                        state.enabled = true;
                    }
                }
                // if profile changed in previous frame
                if (anim.UpdatePreviousAnimation)
                {
                    if (anim.PreviousAnimation != null)
                    {
                        UnityEngine.AnimationState preState = animationComponent[anim.PreviousAnimation];
                        if (preState != null)
                        {
                            animationComponent.Blend(anim.PreviousAnimation, 0, 0.3f);
                        }
                    }
                    anim.UpdatePreviousAnimation = false;
                }
            }
        }