예제 #1
0
 static public int AddEvent(IntPtr l)
 {
     try {
                     #if DEBUG
         var    method     = System.Reflection.MethodBase.GetCurrentMethod();
         string methodName = GetMethodName(method);
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.BeginSample(methodName);
                     #else
         Profiler.BeginSample(methodName);
                     #endif
                     #endif
         UnityEngine.AnimationClip  self = (UnityEngine.AnimationClip)checkSelf(l);
         UnityEngine.AnimationEvent a1;
         checkType(l, 2, out a1);
         self.AddEvent(a1);
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
             #if DEBUG
     finally {
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.EndSample();
                     #else
         Profiler.EndSample();
                     #endif
     }
             #endif
 }
예제 #2
0
    public static void AddAnimEvent(Animator animator, AnimationClip clip, string methodName, float param)
    {
        AnimationEvent ev = new AnimationEvent ();
        ev.functionName = methodName;
        ev.floatParameter = param;

        // at the begining
        ev.time = 0;

        clip.AddEvent (ev);
    }
예제 #3
0
 static public int AddEvent(IntPtr l)
 {
     try {
         UnityEngine.AnimationClip  self = (UnityEngine.AnimationClip)checkSelf(l);
         UnityEngine.AnimationEvent a1;
         checkType(l, 2, out a1);
         self.AddEvent(a1);
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int AddEvent(IntPtr l)
 {
     try{
         UnityEngine.AnimationClip  self = (UnityEngine.AnimationClip)checkSelf(l);
         UnityEngine.AnimationEvent a1;
         checkType(l, 2, out a1);
         self.AddEvent(a1);
         return(0);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
 static int QPYX_AddEvent_YXQP(IntPtr L_YXQP)
 {
     try
     {
         ToLua.CheckArgsCount(L_YXQP, 2);
         UnityEngine.AnimationClip  QPYX_obj_YXQP  = (UnityEngine.AnimationClip)ToLua.CheckObject(L_YXQP, 1, typeof(UnityEngine.AnimationClip));
         UnityEngine.AnimationEvent QPYX_arg0_YXQP = (UnityEngine.AnimationEvent)ToLua.CheckObject(L_YXQP, 2, typeof(UnityEngine.AnimationEvent));
         QPYX_obj_YXQP.AddEvent(QPYX_arg0_YXQP);
         return(0);
     }
     catch (Exception e_YXQP)                {
         return(LuaDLL.toluaL_exception(L_YXQP, e_YXQP));
     }
 }
예제 #6
0
 static int AddEvent(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         UnityEngine.AnimationClip  obj  = (UnityEngine.AnimationClip)ToLua.CheckObject(L, 1, typeof(UnityEngine.AnimationClip));
         UnityEngine.AnimationEvent arg0 = (UnityEngine.AnimationEvent)ToLua.CheckObject(L, 2, typeof(UnityEngine.AnimationEvent));
         obj.AddEvent(arg0);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
예제 #7
0
파일: AnimEvent.cs 프로젝트: zs9024/Jungle
    /// <summary>
    /// 注册无参事件
    /// </summary>
    /// <param name="clip">动画片</param>
    /// <param name="time">事件</param>
    /// <param name="onAnimEvent">回调</param>
    public void AddAnimEvent(AnimationClip clip, float time, System.Action onAnimEvent)
    {
        AnimationEvent animEvent = new AnimationEvent();
        //固定一个事件方法,就不需要对每个事件都写一个
        animEvent.functionName = "OnAnimEvent";
        animEvent.time = time;
        animEvent.messageOptions = SendMessageOptions.RequireReceiver;
        //用hash码记录是哪一个回调函数,还没想到更好的方法
        animEvent.intParameter = onAnimEvent.GetHashCode();

        if (!onAnimEventDic.ContainsKey(animEvent.intParameter))
        {
            onAnimEventDic.Add(animEvent.intParameter, onAnimEvent);
        }

        clip.AddEvent(animEvent);
    }
예제 #8
0
    static int AddEvent(IntPtr L)
    {
#if UNITY_EDITOR
        ToluaProfiler.AddCallRecord("UnityEngine.AnimationClip.AddEvent");
#endif
        try
        {
            ToLua.CheckArgsCount(L, 2);
            UnityEngine.AnimationClip  obj  = (UnityEngine.AnimationClip)ToLua.CheckObject(L, 1, typeof(UnityEngine.AnimationClip));
            UnityEngine.AnimationEvent arg0 = (UnityEngine.AnimationEvent)ToLua.CheckObject(L, 2, typeof(UnityEngine.AnimationEvent));
            obj.AddEvent(arg0);
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
예제 #9
0
파일: AnimEvent.cs 프로젝트: zs9024/Jungle
    public void AddAnimEvent(object obj, AnimationClip clip, float time, System.Action<object> onAnimEventObj)
    {
        AnimationEvent animEvent = new AnimationEvent();
        animEvent.functionName = "OnAnimEventParam";
        animEvent.time = time;
        animEvent.messageOptions = SendMessageOptions.RequireReceiver;
        //用hash码记录回调函数
        animEvent.intParameter = onAnimEventObj.GetHashCode();

        if (!onAnimEventObjDic.ContainsKey(animEvent.intParameter))
        {
            onAnimEventObjDic.Add(animEvent.intParameter, onAnimEventObj);
        }
        if (!paramDic.ContainsKey(animEvent.intParameter))
        {
            paramDic.Add(animEvent.intParameter, obj);
        }

        clip.AddEvent(animEvent);
    }
예제 #10
0
    public static void AddAnimEventAtEnd(Animator animator, AnimationClip clip, string methodName, int param)
    {
        AnimationEvent ev = new AnimationEvent ();
        ev.functionName = methodName;
        ev.intParameter = param;

        // at the begining
        ev.time = clip.length;

        clip.AddEvent (ev);
    }
예제 #11
0
 private static AnimationClip SetEvents(AnimationClip clip, string[] methodNames)
 {
     // AnimationCurveの生成.
     foreach (string methodName in methodNames) {
         AnimationEvent aEvent = new AnimationEvent();
         aEvent.functionName = methodName;
         aEvent.time = 0.1f;
         clip.AddEvent (aEvent);
     }
     return clip;
 }
예제 #12
0
 private static AnimationClip SetEvents(AnimationClip clip, string methodName)
 {
     // AnimationCurveの生成.
     AnimationEvent aEvent = new AnimationEvent();
     aEvent.functionName = methodName;
     aEvent.time = 0.1f;
     clip.AddEvent (aEvent);
     return clip;
 }
예제 #13
0
    protected void AnimationMove( TweenOperandData tweenData )
    {
        Hashtable paramHash = tweenData.paramTable;
        string name = ContainsKey_name( ref paramHash );

        GameObject root = tweenData.tweenTarget;
        if( root == null ){
            ViNoDebugger.LogError( "tween target not found !" );
            return;
        }

        Transform rootra = root.transform;

        if( string.IsNullOrEmpty( name ) ){
            name= "__animation"; // default animation name.
        }

        Animation animation = root.GetComponent<Animation>();
        if( animation == null ){
            animation = root.AddComponent<Animation>();
        }
        AnimationClip clip = new AnimationClip();
        float duration = ContainsKey_duration( ref paramHash );
        bool isMove = false;
        bool isRotate = false;
        bool isScale = false;
        bool isFromPos = false;
        bool isFromRot = false;
        bool isFromScale = false;
        WrapMode  wrapmode = ContainsKey_mode( ref paramHash );
        int method  = 0;
        if( paramHash.ContainsKey( "method" ) ){
            string methodStr = paramHash[ "method" ] as string;
            method = int.Parse( methodStr );
        }
        Vector3 move = ContainsKey_moveXorYorZ( out isMove , ref paramHash , rootra.localPosition );
        Vector3 euler = ContainsKey_rotateXorYorZ( out isRotate , ref paramHash , rootra.localEulerAngles );//localRotation.eulerAngles );
        Vector3 scale = ContainsKey_scaleXorYorZ( 	out isScale , ref paramHash , rootra.localScale );
        Vector3 fromPos = ContainsKey_StrAndXorYorZ( out isFromPos , "fromPos" , ref paramHash , rootra.localPosition );
        Vector3 fromRot = ContainsKey_StrAndXorYorZ( out isFromRot , "fromRot" , ref paramHash , rootra.localEulerAngles );
        Vector3 fromScale = ContainsKey_StrAndXorYorZ( out isFromScale , "fromScale" , ref paramHash , rootra.localScale );
        clip.wrapMode = wrapmode;

        if( isMove ){
            switch( method ){
                case 0 : // Linear.
                    AnimationCurve animCurveX = AnimationCurve.Linear( 0f , fromPos.x , duration , move.x );
                    AnimationCurve animCurveY = AnimationCurve.Linear( 0f , fromPos.y , duration , move.y );
                    AnimationCurve animCurveZ = AnimationCurve.Linear( 0f , fromPos.z , duration , move.z );
                    clip.SetCurve("", typeof(Transform), "localPosition.x", animCurveX );
                    clip.SetCurve("", typeof(Transform), "localPosition.y", animCurveY );
                    clip.SetCurve("", typeof(Transform), "localPosition.z", animCurveZ );
                    break;

                case 1: // Easeinout.
                  animCurveX = AnimationCurve.EaseInOut( 0f , fromPos.x , duration , move.x );
                  animCurveY = AnimationCurve.EaseInOut( 0f , fromPos.y , duration , move.y );
                  animCurveZ = AnimationCurve.EaseInOut( 0f , fromPos.z , duration , move.z );
                  clip.SetCurve("", typeof(Transform), "localPosition.x", animCurveX );
                  clip.SetCurve("", typeof(Transform), "localPosition.y", animCurveY );
                  clip.SetCurve("", typeof(Transform), "localPosition.z", animCurveZ );
                break;
            }
        }

        if( isRotate ){
            Quaternion q1 = Quaternion.Euler( fromRot );
            Quaternion q2 = Quaternion.Euler( euler );

            switch( method ){
                case 0 : // Linear.
                    AnimationCurve animCurveX = AnimationCurve.Linear( 0f , q1.x , duration , q2.x );
                    AnimationCurve animCurveY = AnimationCurve.Linear( 0f , q1.y , duration , q2.y );
                    AnimationCurve animCurveZ = AnimationCurve.Linear( 0f , q1.z , duration , q2.z );
                    AnimationCurve animCurveW = AnimationCurve.Linear( 0f , q1.w , duration , q2.w );

                    clip.SetCurve("", typeof(Transform), "localRotation.x", animCurveX );
                    clip.SetCurve("", typeof(Transform), "localRotation.y", animCurveY );
                    clip.SetCurve("", typeof(Transform), "localRotation.z", animCurveZ );
                    clip.SetCurve("", typeof(Transform), "localRotation.w", animCurveW );
                break;

                case 1: // Easeinout.
                    animCurveX = AnimationCurve.EaseInOut( 0f , q1.x , duration , q2.x );
                    animCurveY = AnimationCurve.EaseInOut( 0f , q1.y , duration , q2.y );
                    animCurveZ = AnimationCurve.EaseInOut( 0f , q1.z , duration , q2.z );
                    animCurveW = AnimationCurve.EaseInOut( 0f , q1.w , duration , q2.w );

                    clip.SetCurve("", typeof(Transform), "localRotation.x", animCurveX );
                    clip.SetCurve("", typeof(Transform), "localRotation.y", animCurveY );
                    clip.SetCurve("", typeof(Transform), "localRotation.z", animCurveZ );
                    clip.SetCurve("", typeof(Transform), "localRotation.w", animCurveW );
                break;
            }
        }

        if( isScale ){
            switch( method ){
                case 0 : // Linear.
                    AnimationCurve animCurveX = AnimationCurve.Linear( 0f , fromScale.x , duration , scale.x );
                    AnimationCurve animCurveY = AnimationCurve.Linear( 0f , fromScale.y , duration , scale.y );
                    AnimationCurve animCurveZ = AnimationCurve.Linear( 0f , fromScale.z , duration , scale.z );
                    clip.SetCurve("", typeof(Transform), "localScale.x", animCurveX );
                    clip.SetCurve("", typeof(Transform), "localScale.y", animCurveY );
                    clip.SetCurve("", typeof(Transform), "localScale.z", animCurveZ );
                    break;
                case 1: // Easeinout.
                    animCurveX = AnimationCurve.EaseInOut( 0f , fromScale.x , duration , scale.x );
                    animCurveY = AnimationCurve.EaseInOut( 0f , fromScale.y , duration , scale.y );
                    animCurveZ = AnimationCurve.EaseInOut( 0f , fromScale.z , duration , scale.z );
                    clip.SetCurve("", typeof(Transform), "localScale.x", animCurveX );
                    clip.SetCurve("", typeof(Transform), "localScale.y", animCurveY );
                    clip.SetCurve("", typeof(Transform), "localScale.z", animCurveZ );
                    break;
            }
        }

        ViNoAnimationListener animcb = root.GetComponent<ViNoAnimationListener>();
        if( animcb == null ){
            root.AddComponent<ViNoAnimationListener>();
        }

        AnimationEvent tweenFinished = new AnimationEvent();
        tweenFinished.time = duration;
        tweenFinished.intParameter = 123;
        tweenFinished.stringParameter = "end";
        tweenFinished.functionName = "AnimationFinishedCallback";

        clip.AddEvent( tweenFinished );

        animation.AddClip(clip, name );

        // Now, Start the Animation.
        animation.Play( name );

        // Is  paramHash Contains Key "sendDelay" ? .
        ContainsKey_sendDelayAndStartCoroutine( ref paramHash );
    }
예제 #14
0
    private void AddAnimationMoveToPlayerDeck(Vector3 endPosition)
    {
        var clip = new AnimationClip();
        var curve = AnimationCurve.EaseInOut(0, transform.position.x, 1, endPosition.x);
        clip.SetCurve("",typeof(Transform),"localPosition.x", curve);
        curve = AnimationCurve.EaseInOut(0, transform.position.y, 0.7f, 0f);
        clip.SetCurve("",typeof(Transform),"localPosition.y", curve);
        curve = new AnimationCurve();
        curve.AddKey(0, transform.position.z);
        var keyframe = curve[0];
        keyframe.outTangent = 1;
        curve.MoveKey(0, keyframe);
        curve.AddKey(0.4f, transform.position.z-2.5f);
        curve.AddKey(0.70f, transform.position.z-4.7f);
        curve.AddKey(1f, endPosition.z);
        keyframe = curve[3];
        keyframe.inTangent = 0;
        curve.MoveKey(3, keyframe);
        clip.SetCurve("",typeof(Transform),"localPosition.z", curve);
        clip.wrapMode = WrapMode.Once;

        var animEv= new AnimationEvent();
        animEv.functionName="animFinished";
        animEv.time=clip.length;
        clip.AddEvent(animEv);

        clip.legacy = true;
        GetComponent<Animation>().AddClip(clip, "MoveToPlayerDeckAnimation");
    }
예제 #15
0
    public static void MoveTo( GameObject target , Vector3 position , float time )
    {
        Vector3 fromPos = target.transform.localPosition;

        Animation animation = target.GetComponent<Animation>();
        if( animation == null ){
            animation = target.AddComponent<Animation>();
        }
        AnimationClip clip = new AnimationClip();
        //        clip.wrapMode = WrapMode.;
        AnimationCurve animCurveX = AnimationCurve.Linear( 0f , fromPos.x , time , position.x );
        AnimationCurve animCurveY = AnimationCurve.Linear( 0f , fromPos.y , time , position.y );
        AnimationCurve animCurveZ = AnimationCurve.Linear( 0f , fromPos.z , time , position.z );
        clip.SetCurve("", typeof(Transform), "localPosition.x", animCurveX );
        clip.SetCurve("", typeof(Transform), "localPosition.y", animCurveY );
        clip.SetCurve("", typeof(Transform), "localPosition.z", animCurveZ );

        ViNoAnimationListener animcb = target.GetComponent<ViNoAnimationListener>();
        if( animcb == null ){
            target.AddComponent<ViNoAnimationListener>();
        }

        AnimationEvent tweenFinished = new AnimationEvent();
        tweenFinished.time = time;
        tweenFinished.intParameter = 123;
        tweenFinished.stringParameter = "end";
        tweenFinished.functionName = "AnimationFinishedCallback";

        clip.AddEvent( tweenFinished );

        animation.AddClip(clip, target.name );

        // Now, Start the Animation.
        animation.Play( target.name );
    }