public override void ProcessFrame(UnityEngine.Playables.Playable playable, UnityEngine.Playables.FrameData info, object playerData) { if (parameter != null) { // If we are overriding the track object, the rtpcObject will have been resolved in AkRTPCPlayable::CreatePlayable(). if (!overrideTrackObject) { // At this point, rtpcObject will have been set to the timeline owner object in AkRTPCPlayable::CreatePlayable(). // If the track object is null, we keep using the timeline owner object. Otherwise, we swap it for the track object. var obj = playerData as UnityEngine.GameObject; if (obj != null) { rtpcObject = obj; } } if (setRTPCGlobally || rtpcObject == null) { parameter.SetGlobalValue(RTPCValue); } else { parameter.SetValue(rtpcObject, RTPCValue); } } base.ProcessFrame(playable, info, playerData); }
static object PerformMemberwiseClone(ref object o) { var ins = new UnityEngine.Playables.FrameData(); ins = (UnityEngine.Playables.FrameData)o; return(ins); }
public override void PrepareFrame(UnityEngine.Playables.Playable playable, UnityEngine.Playables.FrameData info) { base.PrepareFrame(playable, info); if (akEvent == null) { return; } var shouldPlay = ShouldPlay(playable); if (IsScrubbing(info) && shouldPlay) { requiredActions |= Actions.Seek; if (!eventIsPlaying) { requiredActions |= Actions.Playback | Actions.DelayedStop; CheckForFadeInFadeOut(playable); } } else if (!eventIsPlaying && (requiredActions & Actions.Playback) == 0) { // The clip is playing but the event hasn't been triggered. We need to start the event and jump to the correct time. requiredActions |= Actions.Retrigger; CheckForFadeInFadeOut(playable); } else { CheckForFadeOut(playable, UnityEngine.Playables.PlayableExtensions.GetTime(playable)); } }
public override void OnBehaviourPause(UnityEngine.Playables.Playable playable, UnityEngine.Playables.FrameData info) { if (eventObject != null) { stopEvent(); } }
static StackObject *ProcessFrame_7(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { CSHotFix.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 4); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); System.Object @playerData = (System.Object) typeof(System.Object).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); ptr_of_this_method = ILIntepreter.Minus(__esp, 2); UnityEngine.Playables.FrameData @info = (UnityEngine.Playables.FrameData) typeof(UnityEngine.Playables.FrameData).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); ptr_of_this_method = ILIntepreter.Minus(__esp, 3); UnityEngine.Playables.Playable @playable = (UnityEngine.Playables.Playable) typeof(UnityEngine.Playables.Playable).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); ptr_of_this_method = ILIntepreter.Minus(__esp, 4); UnityEngine.Playables.IPlayableBehaviour instance_of_this_method; instance_of_this_method = (UnityEngine.Playables.IPlayableBehaviour) typeof(UnityEngine.Playables.IPlayableBehaviour).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); instance_of_this_method.ProcessFrame(@playable, @info, @playerData); return(__ret); }
public override void OnBehaviourPlay(UnityEngine.Playables.Playable playable, UnityEngine.Playables.FrameData info) { if (akEvent != null) { if (ShouldPlay(playable)) { requiredActions |= AkPlayableAction.Playback; // If we've explicitly set the playhead, only play a small snippet. // We disable scrubbing in edit mode, due to an issue with how FrameData.EvaluationType is handled in edit mode. // This is a known issue and Unity are aware of it: https://fogbugz.unity3d.com/default.asp?953109_kitf7pso0vmjm0m0 if (info.evaluationType == UnityEngine.Playables.FrameData.EvaluationType.Evaluate && UnityEngine.Application.isPlaying) { requiredActions |= AkPlayableAction.DelayedStop; checkForFadeIn((float)UnityEngine.Playables.PlayableExtensions.GetTime(playable)); checkForFadeOut(playable); } else { var proportionalTime = getProportionalTime(playable); var alph = 0.05f; // we need to jump to the correct position in the case where the event is played from some non-start position. if (proportionalTime > alph) { requiredActions |= AkPlayableAction.Seek; } checkForFadeIn((float)UnityEngine.Playables.PlayableExtensions.GetTime(playable)); checkForFadeOut(playable); } } } }
public override void PrepareFrame(UnityEngine.Playables.Playable playable, UnityEngine.Playables.FrameData info) { if (eventTracker != null) { // We disable scrubbing in edit mode, due to an issue with how FrameData.EvaluationType is handled in edit mode. // This is a known issue and Unity are aware of it: https://fogbugz.unity3d.com/default.asp?953109_kitf7pso0vmjm0m0 var scrubbing = info.evaluationType == UnityEngine.Playables.FrameData.EvaluationType.Evaluate && UnityEngine.Application.isPlaying; if (scrubbing && ShouldPlay(playable)) { if (!eventTracker.eventIsPlaying) { requiredActions |= AkPlayableAction.Playback; requiredActions |= AkPlayableAction.DelayedStop; checkForFadeIn((float)UnityEngine.Playables.PlayableExtensions.GetTime(playable)); checkForFadeOut(playable); } requiredActions |= AkPlayableAction.Seek; } else // The clip is playing but the event hasn't been triggered. We need to start the event and jump to the correct time. { if (!eventTracker.eventIsPlaying && (requiredActions & AkPlayableAction.Playback) == 0) { requiredActions |= AkPlayableAction.Retrigger; checkForFadeIn((float)UnityEngine.Playables.PlayableExtensions.GetTime(playable)); } checkForFadeOut(playable); } } }
public override void OnBehaviourPlay(UnityEngine.Playables.Playable playable, UnityEngine.Playables.FrameData info) { base.OnBehaviourPlay(playable, info); if (akEvent == null) { return; } var shouldPlay = ShouldPlay(playable); if (!shouldPlay) { return; } requiredActions |= Actions.Playback; if (IsScrubbing(info)) { wasScrubbingAndRequiresRetrigger = true; // If we've explicitly set the playhead, only play a small snippet. requiredActions |= Actions.DelayedStop; } else if (GetProportionalTime(playable) > alph) { // we need to jump to the correct position in the case where the event is played from some non-start position. requiredActions |= Actions.Seek; } CheckForFadeInFadeOut(playable); }
public override void OnBehaviourPause(UnityEngine.Playables.Playable playable, UnityEngine.Playables.FrameData info) { base.OnBehaviourPause(playable, info); if (eventObject != null && akEvent != null && StopEventAtClipEnd) { StopEvent(); } }
public override void OnBehaviourPause(UnityEngine.Playables.Playable playable, UnityEngine.Playables.FrameData info) { wasScrubbingAndRequiresRetrigger = false; base.OnBehaviourPause(playable, info); if (eventObject != null && akEvent != null && StopEventAtClipEnd) { StopEvent(); } }
public override void ProcessFrame(UnityEngine.Playables.Playable playable, UnityEngine.Playables.FrameData info, object playerData) { base.ProcessFrame(playable, info, playerData); if (akEvent == null) { return; } if (!overrideTrackEmitterObject) { var obj = playerData as UnityEngine.GameObject; if (obj != null) { eventObject = obj; } } if (eventObject == null) { return; } if ((requiredActions & Actions.Playback) != 0) { PlayEvent(); } if ((requiredActions & Actions.Seek) != 0) { SeekToTime(playable); } if ((retriggerEvent || wasScrubbingAndRequiresRetrigger) && (requiredActions & Actions.Retrigger) != 0) { RetriggerEvent(playable); } if ((requiredActions & Actions.DelayedStop) != 0) { StopEvent(scrubPlaybackLengthMs); } if (!fadeinTriggered && (requiredActions & Actions.FadeIn) != 0) { TriggerFadeIn(playable); } if (!fadeoutTriggered && (requiredActions & Actions.FadeOut) != 0) { TriggerFadeOut(playable); } requiredActions = Actions.None; }
void PrintInfo(string FunctionName, UnityEngine.Playables.Playable playable, UnityEngine.Playables.FrameData info) { if (PrintDebugInformation) { var previousTime = UnityEngine.Playables.PlayableExtensions.GetPreviousTime(playable); var currentTime = UnityEngine.Playables.PlayableExtensions.GetTime(playable); var computedDelta = System.Math.Abs(currentTime - previousTime); UnityEngine.Debug.Log($"{FunctionName}: prevTime={previousTime}; curTime={currentTime}; computedDelta={computedDelta}; evalType={info.evaluationType}; deltaTime={info.deltaTime}; playState={info.effectivePlayState}; timeHeld={info.timeHeld}; speed={info.effectiveSpeed}; parentSpeed={info.effectiveParentSpeed}"); } }
private bool IsScrubbing(UnityEngine.Playables.FrameData info) { #if !UNITY_2018_2_OR_NEWER // We disable scrubbing in edit mode, due to an issue with how FrameData.EvaluationType is handled in edit mode. // This is a known issue and Unity are aware of it: https://fogbugz.unity3d.com/default.asp?953109_kitf7pso0vmjm0m0 if (!UnityEngine.Application.isPlaying) { return(false); } #endif return(info.evaluationType == UnityEngine.Playables.FrameData.EvaluationType.Evaluate); }
public override void ProcessFrame(UnityEngine.Playables.Playable playable, UnityEngine.Playables.FrameData info, object playerData) { if (!overrideTrackEmittorObject) { var obj = playerData as UnityEngine.GameObject; if (obj != null) { eventObject = obj; } } if (eventObject != null) { var clipTime = (float)UnityEngine.Playables.PlayableExtensions.GetTime(playable); if (actionIsRequired(AkPlayableAction.Playback)) { playEvent(); } if (eventShouldRetrigger && actionIsRequired(AkPlayableAction.Retrigger)) { retriggerEvent(playable); } if (actionIsRequired(AkPlayableAction.Stop)) { akEvent.Stop(eventObject); } if (actionIsRequired(AkPlayableAction.DelayedStop)) { stopEvent(scrubPlaybackLengthMs); } if (actionIsRequired(AkPlayableAction.Seek)) { seekToTime(playable); } if (actionIsRequired(AkPlayableAction.FadeIn)) { triggerFadeIn(clipTime); } if (actionIsRequired(AkPlayableAction.FadeOut)) { var timeLeft = (float)(UnityEngine.Playables.PlayableExtensions.GetDuration(playable) - UnityEngine.Playables.PlayableExtensions.GetTime(playable)); triggerFadeOut(timeLeft); } } requiredActions = (uint)AkPlayableAction.None; }
static void WriteBackInstance(CSHotFix.Runtime.Enviorment.AppDomain __domain, StackObject *ptr_of_this_method, IList <object> __mStack, ref UnityEngine.Playables.FrameData instance_of_this_method) { ptr_of_this_method = ILIntepreter.GetObjectAndResolveReference(ptr_of_this_method); switch (ptr_of_this_method->ObjectType) { case ObjectTypes.Object: { __mStack[ptr_of_this_method->Value] = instance_of_this_method; } break; case ObjectTypes.FieldReference: { var ___obj = __mStack[ptr_of_this_method->Value]; if (___obj is ILTypeInstance) { ((ILTypeInstance)___obj)[ptr_of_this_method->ValueLow] = instance_of_this_method; } else { var t = __domain.GetType(___obj.GetType()) as CLRType; t.SetFieldValue(ptr_of_this_method->ValueLow, ref ___obj, instance_of_this_method); } } break; case ObjectTypes.StaticFieldReference: { var t = __domain.GetType(ptr_of_this_method->Value); if (t is ILType) { ((ILType)t).StaticInstance[ptr_of_this_method->ValueLow] = instance_of_this_method; } else { ((CLRType)t).SetStaticFieldValue(ptr_of_this_method->ValueLow, instance_of_this_method); } } break; case ObjectTypes.ArrayReference: { var instance_of_arrayReference = __mStack[ptr_of_this_method->Value] as UnityEngine.Playables.FrameData[]; instance_of_arrayReference[ptr_of_this_method->ValueLow] = instance_of_this_method; } break; } }
private bool IsScrubbing(UnityEngine.Playables.Playable playable, UnityEngine.Playables.FrameData info) { #if UNITY_EDITOR if (!UnityEngine.Application.isPlaying) { return(info.evaluationType == UnityEngine.Playables.FrameData.EvaluationType.Evaluate); } #endif var previousTime = UnityEngine.Playables.PlayableExtensions.GetPreviousTime(playable); var currentTime = UnityEngine.Playables.PlayableExtensions.GetTime(playable); var computedDelta = System.Math.Abs(currentTime - previousTime); // Unfortunately, we can't use info.seekOccurred, because it is always true. // When time is explicitely set using playable.time, deltaTime is zero, evaluationType is Evaluate, and // either previous time or current time is non-zero // However, if time is added to playable.time (for example, playable.time += 1;), evaluationType remains // Playing. return((info.deltaTime == 0 && (previousTime > 0 || currentTime > 0)) || (computedDelta > info.deltaTime)); }
private bool IsScrubbing(UnityEngine.Playables.Playable playable, UnityEngine.Playables.FrameData info) { if (info.evaluationType != UnityEngine.Playables.FrameData.EvaluationType.Evaluate) { return(false); } #if UNITY_EDITOR if (!UnityEngine.Application.isPlaying) { return(true); } #endif var previousTime = UnityEngine.Playables.PlayableExtensions.GetPreviousTime(playable); var currentTime = UnityEngine.Playables.PlayableExtensions.GetTime(playable); // Unfortunately, we can't use info.seekOccurred, because it is always true. // When time is explicitely set using playable.time, deltaTime is zero, evaluationType is Evaluate, and // either previous time or current time is non-zero return(info.deltaTime == 0 && (previousTime > 0 || currentTime > 0)); }
public override void PrepareFrame(UnityEngine.Playables.Playable playable, UnityEngine.Playables.FrameData info) { base.PrepareFrame(playable, info); PrintInfo("PrepareFrame", playable, info); if (akEvent == null) { return; } var shouldPlay = ShouldPlay(playable); if (IsScrubbing(playable, info) && shouldPlay) { requiredActions |= Actions.Seek; if (!eventIsPlaying) { requiredActions |= Actions.Playback; #if UNITY_EDITOR if (!UnityEngine.Application.isPlaying) { // If we've explicitly set the playhead, only play a small snippet. requiredActions |= Actions.DelayedStop; } #endif CheckForFadeInFadeOut(playable); } } else if (!eventIsPlaying && (requiredActions & Actions.Playback) == 0) { // The clip is playing but the event hasn't been triggered. We need to start the event and jump to the correct time. requiredActions |= Actions.Retrigger; CheckForFadeInFadeOut(playable); } else { CheckForFadeOut(playable, UnityEngine.Playables.PlayableExtensions.GetTime(playable)); } }
public override void ProcessFrame(UnityEngine.Playables.Playable playable, UnityEngine.Playables.FrameData frameData, object playerData) { base.ProcessFrame(playable, frameData, playerData); if (RTPC == null) { return; } var obj = playerData as UnityEngine.GameObject; if (obj != null) { gameObject = obj; } if (setGlobally) { RTPC.SetGlobalValue(value); } else if (gameObject) { RTPC.SetValue(gameObject, value); } }