コード例 #1
0
        public override void OnBehaviourPause(UnityEngine.Playables.Playable playable, FrameData info)
        {
            if (Target == null)
            {
                return;
            }

            UpdateTime(Time(playable));

            if (Target.IsPlaying)
            {
                //do nothing, as we should hold the current time, and the animation is already in manual mode
                if (isGoingForwards)
                {
                    Target.GoToTime(Target.Duration);
                }
                else
                {
                    Target.GoToTime(0);
                }
            }
            else
            {
                if (!HoldOnDone)
                {
                    Target.GoToTime(0);
                    //reset to the inital time
                }

                //do nothing to hold the last value in place
            }
        }
コード例 #2
0
    static int Create(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 1)
            {
                UnityEngine.Playables.PlayableGraph arg0 = StackTraits <UnityEngine.Playables.PlayableGraph> .Check(L, 1);

                UnityEngine.Playables.Playable o = UnityEngine.Playables.Playable.Create(arg0);
                ToLua.PushValue(L, o);
                return(1);
            }
            else if (count == 2)
            {
                UnityEngine.Playables.PlayableGraph arg0 = StackTraits <UnityEngine.Playables.PlayableGraph> .Check(L, 1);

                int arg1 = (int)LuaDLL.luaL_checknumber(L, 2);
                UnityEngine.Playables.Playable o = UnityEngine.Playables.Playable.Create(arg0, arg1);
                ToLua.PushValue(L, o);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: UnityEngine.Playables.Playable.Create"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
コード例 #3
0
 static public int constructor(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.Playables.Playable o;
         o = new UnityEngine.Playables.Playable();
         pushValue(l, true);
         pushValue(l, o);
         return(2);
     }
     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
 }
コード例 #4
0
 public override void OnGraphStart(UnityEngine.Playables.Playable playable)
 {
     previousType      = Target.UpdateMode;
     Target.UpdateMode = AnimationUpdateType.MANUAL;
     //directly jump to the start time
     Target?.GoToTime(Time(playable));
     playable.SetPropagateSetTime(true);
 }
コード例 #5
0
        public override void OnBehaviourPlay(UnityEngine.Playables.Playable playable, FrameData info)
        {
            //TODO add a function in all animation to "reset init state" for when it stops,
            //TODO because it's not enough in case of from tween

            Target.UpdateMode = AnimationUpdateType.MANUAL;
            Target.Play();
            Target?.GoToTime(Time(playable));
        }
コード例 #6
0
        private float Time(UnityEngine.Playables.Playable playable)
        {
            if (PlayReversed)
            {
                return((float)(playable.GetDuration() - playable.GetTime()));
            }

            return((float)playable.GetTime());
        }
コード例 #7
0
        public void OnNotify
            (UnityEngine.Playables.Playable origin, INotification notification, object context)
        {
            var mtrkEvent = ((MidiSignal)notification).Event;

            onFireEvent?.Invoke(mtrkEvent);
            if (noteFilter.Check(mtrkEvent, out var noteEvent))
            {
                (noteEvent is OnNoteEvent ? noteOnEvent : noteOffEvent).Invoke();
            }
        }
コード例 #8
0
 //----------------------------------------------------------------------------
 // PlayableGraphのProcessFrameフェーズの間に呼び出される
 // ProcessFrameはあなたのPlayableがその仕事をする段階です。
 // PlayableがPlayPlayableOutputを直接または間接的に再生して接続するときに、各フレームに対して呼び出されます。
 public override void ProcessFrame(
     UnityEngine.Playables.Playable playable,
     UnityEngine.Playables.FrameData info,
     object playerData
     )
 {
     if (Application.isPlaying)
     {
         luaUpdate?.Invoke();
     }
 }
コード例 #9
0
        public override void ProcessFrame(UnityEngine.Playables.Playable playable, FrameData info, object playerData)
        {
            Target?.GoToTime(Time(playable));
            UpdateTime((float)playable.GetTime());

#if UNITY_EDITOR
            if (!Application.isPlaying)
            {
                Target.ManualUpdate(0);
            }
#endif
        }
コード例 #10
0
        public override void PrepareFrame(UnityEngine.Playables.Playable playable, FrameData info)
        {
            _playable  = playable;
            _frameData = info;
            var currentTime = (float)playable.GetTime();

            if (info.evaluationType == FrameData.EvaluationType.Playback)
            {
                _trackPlayer.PlayByDeltaTime(currentTime - _previousTime);
            }
            _previousTime = currentTime;
        }
コード例 #11
0
    //----------------------------------------------------------------------------
    // PlayState.Pausedに変更されたときに呼び出される
    public override void OnBehaviourPause(
        UnityEngine.Playables.Playable playable,
        UnityEngine.Playables.FrameData info
        )
    {
        luaOnDestroy?.Invoke();
        luaOnDestroy = null;

        scriptEnv?.Dispose();
        scriptEnv = null;
        luaUpdate = null;
    }
コード例 #12
0
	static public int op_Implicit_s(IntPtr l) {
		try {
			UnityEngine.Audio.AudioClipPlayable a1;
			checkValueType(l,1,out a1);
			UnityEngine.Playables.Playable ret=a1;
			pushValue(l,true);
			pushValue(l,ret);
			return 2;
		}
		catch(Exception e) {
			return error(l,e);
		}
	}
コード例 #13
0
 static public int ctor_s(IntPtr l)
 {
     try {
         UnityEngine.Playables.Playable o;
         o = new UnityEngine.Playables.Playable();
         pushValue(l, true);
         pushValue(l, o);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int op_Implicit_s(IntPtr l)
 {
     try {
         UnityEngine.Animations.AnimatorControllerPlayable a1;
         checkValueType(l, 1, out a1);
         UnityEngine.Playables.Playable ret = a1;
         pushValue(l, true);
         pushValue(l, ret);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
コード例 #15
0
        public override void OnBehaviourPause(UnityEngine.Playables.Playable playable, FrameData info)
        {
            // When the playable is being finished, signals laying in the rest
            // of the clip should be all triggered.
            if (!playable.IsDone())
            {
                return;
            }
            _playable  = playable;
            _frameData = info;
            var currentTime = (float)playable.GetDuration();

            _trackPlayer.PlayByDeltaTime(_previousTime - currentTime);
            _previousTime = currentTime;
        }
コード例 #16
0
        public override void OnPlayableCreate(UnityEngine.Playables.Playable playable)
        {
            var resolver = playable.GetGraph().GetResolver();

            // Populate actions for the each controller.
            _actions = new ControlAction[controls.Length];

            for (var i = 0; i < controls.Length; i++)
            {
                _actions[i] = ControlAction.CreateAction(
                    controls[i].targetComponent.Resolve(resolver),
                    controls[i].propertyName
                    );
            }
        }
コード例 #17
0
 static int GetPlayableType(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         UnityEngine.Playables.Playable obj = (UnityEngine.Playables.Playable)ToLua.CheckObject(L, 1, typeof(UnityEngine.Playables.Playable));
         System.Type o = obj.GetPlayableType();
         ToLua.Push(L, o);
         ToLua.SetBack(L, 1, obj);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
コード例 #18
0
    static int Equals(IntPtr L)
    {
        try
        {
            ToLua.CheckArgsCount(L, 2);
            UnityEngine.Playables.Playable obj  = (UnityEngine.Playables.Playable)ToLua.CheckObject(L, 1, typeof(UnityEngine.Playables.Playable));
            UnityEngine.Playables.Playable arg0 = StackTraits <UnityEngine.Playables.Playable> .Check(L, 2);

            bool o = obj.Equals(arg0);
            LuaDLL.lua_pushboolean(L, o);
            ToLua.SetBack(L, 1, obj);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
コード例 #19
0
    static int CreatePlayable(IntPtr L)
    {
        try
        {
            ToLua.CheckArgsCount(L, 3);
            UnityEngine.Timeline.TimelineAsset  obj  = (UnityEngine.Timeline.TimelineAsset)ToLua.CheckObject <UnityEngine.Timeline.TimelineAsset>(L, 1);
            UnityEngine.Playables.PlayableGraph arg0 = StackTraits <UnityEngine.Playables.PlayableGraph> .Check(L, 2);

            UnityEngine.GameObject         arg1 = (UnityEngine.GameObject)ToLua.CheckObject(L, 3, typeof(UnityEngine.GameObject));
            UnityEngine.Playables.Playable o    = obj.CreatePlayable(arg0, arg1);
            ToLua.PushValue(L, o);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
コード例 #20
0
        public float GetValue(UnityEngine.Playables.Playable playable, MidiControl control)
        {
            var t = (float)(playable.GetTime() % midiTrack.TotalSeconds);

            switch (control.mode)
            {
            case MidiControl.Mode.NoteEnvelope:
                return(GetNoteEnvelopeValue(control, t));

            case MidiControl.Mode.NoteCurve:
                return(GetNoteCurveValue(control, t));

            case MidiControl.Mode.CC:
                return(GetCCValue(control, t));

            default:
                return(0);
            }
        }
コード例 #21
0
        public override void ProcessFrame(UnityEngine.Playables.Playable playable, FrameData info, object playerData)
        {
            for (var ci = 0; ci < controls.Length; ci++)
            {
                var ctrl = controls[ci];
                if (!ctrl.enabled)
                {
                    continue;
                }

                // Controller value accumulation
                var acc = 0.0f;

                for (var i = 0; i < playable.GetInputCount(); i++)
                {
                    var clip = (ScriptPlayable <MidiAnimation>)playable.GetInput(i);
                    acc += playable.GetInputWeight(i) *
                           clip.GetBehaviour().GetValue(clip, ctrl);
                }

                // Controller action invocation
                _actions[ci]?.Invoke(Vector4.Lerp(ctrl.vector0, ctrl.vector1, acc));
            }
        }
コード例 #22
0
    //----------------------------------------------------------------------------
    // PlayState.Playingに変更されたときに呼び出される
    public override void OnBehaviourPlay(
        UnityEngine.Playables.Playable playable,
        UnityEngine.Playables.FrameData info
        )
    {
        if (textAsset != null)
        {
            scriptEnv = LuaEngine.LuaEnv.NewTable();
            // スクリプトごとに別々の環境を設定すると、スクリプト間でのグローバル変数と関数の競合をある程度防ぐことができます。
            XLua.LuaTable meta = LuaEngine.LuaEnv.NewTable();
            meta.Set("__index", LuaEngine.LuaEnv.Global);
            scriptEnv.SetMetaTable(meta);
            meta.Dispose();

            scriptEnv.Set("self", owner);
            LuaEngine.LuaEnv.DoString(textAsset.text, textAsset.GetHashCode().ToString(), scriptEnv);

            Action luaAwake = scriptEnv.Get <Action>("awake");
            scriptEnv.Get("update", out luaUpdate);
            scriptEnv.Get("ondestroy", out luaOnDestroy);

            luaAwake?.Invoke();
        }
    }
コード例 #23
0
 // Called each frame while the state is set to Play
 public override void PrepareFrame(UnityEngine.Playables.Playable playable, FrameData info)
 {
 }
コード例 #24
0
 // Called when the state of the playable is set to Paused
 public override void OnBehaviourPause(UnityEngine.Playables.Playable playable, FrameData info)
 {
 }
コード例 #25
0
 // Called when the state of the playable is set to Play
 public override void OnBehaviourPlay(UnityEngine.Playables.Playable playable, FrameData info)
 {
     effectEvent.PlayEvent(eventName);
 }
コード例 #26
0
 // Called when the owning graph stops playing
 public override void OnGraphStop(UnityEngine.Playables.Playable playable)
 {
 }
コード例 #27
0
ファイル: TimeScalePlayable.cs プロジェクト: ShinyGX/DarkSoul
 // Called each frame while the state is set to Play
 public override void PrepareFrame(UnityEngine.Playables.Playable playable, FrameData info)
 {
     curTime       += Time.deltaTime;
     Time.timeScale = curve.Evaluate(curTime / maxTime);
 }
コード例 #28
0
ファイル: TimeScalePlayable.cs プロジェクト: ShinyGX/DarkSoul
 // Called when the state of the playable is set to Play
 public override void OnBehaviourPlay(UnityEngine.Playables.Playable playable, FrameData info)
 {
     maxTime = (float)playable.GetDuration();
 }
コード例 #29
0
ファイル: TimeScalePlayable.cs プロジェクト: ShinyGX/DarkSoul
 // Called when the owning graph stops playing
 public override void OnGraphStop(UnityEngine.Playables.Playable playable)
 {
     Time.timeScale = 1;
 }
コード例 #30
0
 // Called when the state of the playable is set to Play
 public override void OnBehaviourPlay(UnityEngine.Playables.Playable playable, FrameData info)
 {
     damageable.TryGetDamage(data);
 }