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 } }
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)); } }
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 }
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); }
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)); }
private float Time(UnityEngine.Playables.Playable playable) { if (PlayReversed) { return((float)(playable.GetDuration() - playable.GetTime())); } return((float)playable.GetTime()); }
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(); } }
//---------------------------------------------------------------------------- // 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(); } }
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 }
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; }
//---------------------------------------------------------------------------- // PlayState.Pausedに変更されたときに呼び出される public override void OnBehaviourPause( UnityEngine.Playables.Playable playable, UnityEngine.Playables.FrameData info ) { luaOnDestroy?.Invoke(); luaOnDestroy = null; scriptEnv?.Dispose(); scriptEnv = null; luaUpdate = null; }
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); } }
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)); } }
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; }
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 ); } }
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)); } }
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)); } }
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)); } }
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); } }
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)); } }
//---------------------------------------------------------------------------- // 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(); } }
// Called each frame while the state is set to Play public override void PrepareFrame(UnityEngine.Playables.Playable playable, FrameData info) { }
// Called when the state of the playable is set to Paused public override void OnBehaviourPause(UnityEngine.Playables.Playable playable, FrameData info) { }
// Called when the state of the playable is set to Play public override void OnBehaviourPlay(UnityEngine.Playables.Playable playable, FrameData info) { effectEvent.PlayEvent(eventName); }
// Called when the owning graph stops playing public override void OnGraphStop(UnityEngine.Playables.Playable playable) { }
// 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); }
// 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(); }
// Called when the owning graph stops playing public override void OnGraphStop(UnityEngine.Playables.Playable playable) { Time.timeScale = 1; }
// Called when the state of the playable is set to Play public override void OnBehaviourPlay(UnityEngine.Playables.Playable playable, FrameData info) { damageable.TryGetDamage(data); }