Unity-jump-proj
This commit is contained in:
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Playables;
|
||||
using UnityEngine.Timeline;
|
||||
|
||||
namespace Timeline.Samples
|
||||
{
|
||||
// Runtime representation of a time dilation clip.
|
||||
// The Serializable attribute is required to be animated by timeline, and used as a template.
|
||||
[Serializable]
|
||||
public class TimeDilationBehaviour : PlayableBehaviour
|
||||
{
|
||||
[Tooltip("Time.timeScale replacement value.")]
|
||||
public float timeScale = 1f;
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e908c2fc95a400b41b3277d302f3d703
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,47 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.Playables;
|
||||
using UnityEngine.Timeline;
|
||||
|
||||
namespace Timeline.Samples
|
||||
{
|
||||
// A track mixer behaviour that modifies the timeScale. This affects how fast the game plays back
|
||||
public class TimeDilationMixerBehaviour : PlayableBehaviour
|
||||
{
|
||||
private float m_DefaultTimeScale = 1;
|
||||
|
||||
// Called every frame that the timeline is Evaluated.
|
||||
public override void ProcessFrame(Playable playable, FrameData info, object playerData)
|
||||
{
|
||||
int inputCount = playable.GetInputCount();
|
||||
float timeScale = 0f;
|
||||
float totalWeight = 0f;
|
||||
|
||||
// blend clips together
|
||||
for (int i = 0; i < inputCount; i++)
|
||||
{
|
||||
float inputWeight = playable.GetInputWeight(i);
|
||||
|
||||
ScriptPlayable<TimeDilationBehaviour> playableInput = (ScriptPlayable<TimeDilationBehaviour>)playable.GetInput(i);
|
||||
TimeDilationBehaviour input = playableInput.GetBehaviour();
|
||||
|
||||
timeScale += inputWeight * input.timeScale;
|
||||
totalWeight += inputWeight;
|
||||
}
|
||||
|
||||
// blend to/from the default timeline
|
||||
Time.timeScale = Mathf.Max(0.0001f, Mathf.Lerp(m_DefaultTimeScale, timeScale, Mathf.Clamp01(totalWeight)));
|
||||
}
|
||||
|
||||
// Called when the playable graph is created, typically when the timeline is played.
|
||||
public override void OnPlayableCreate(Playable playable)
|
||||
{
|
||||
m_DefaultTimeScale = Time.timeScale;
|
||||
}
|
||||
|
||||
// Called when the playable is destroyed, typically when the timeline stops.
|
||||
public override void OnPlayableDestroy(Playable playable)
|
||||
{
|
||||
Time.timeScale = m_DefaultTimeScale;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f129802fb1f001541bac69052c7afae6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Playables;
|
||||
using UnityEngine.Timeline;
|
||||
|
||||
namespace Timeline.Samples
|
||||
{
|
||||
// A clip for the timeline dilation track.
|
||||
[Serializable]
|
||||
public class TimeDilationPlayableAsset : PlayableAsset, ITimelineClipAsset
|
||||
{
|
||||
// Using a template for the playable behaviour will allow any serializable fields on the behaviour
|
||||
// to be animated.
|
||||
[NoFoldOut]
|
||||
public TimeDilationBehaviour template = new TimeDilationBehaviour();
|
||||
|
||||
// Implementation of ITimelineClipAsset, that tells the timeline editor which
|
||||
// features this clip supports.
|
||||
public ClipCaps clipCaps
|
||||
{
|
||||
get { return ClipCaps.Extrapolation | ClipCaps.Blending; }
|
||||
}
|
||||
|
||||
// Called to creates a runtime instance of the clip.
|
||||
public override Playable CreatePlayable(PlayableGraph graph, GameObject owner)
|
||||
{
|
||||
// Note that template is passed as a parameter - this
|
||||
// creates a clone of the template PlayableBehaviour.
|
||||
return ScriptPlayable<TimeDilationBehaviour>.Create(graph, template);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f7b94fe8674371d49bfc8b9f90de6108
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,22 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.Playables;
|
||||
using UnityEngine.Timeline;
|
||||
|
||||
namespace Timeline.Samples
|
||||
{
|
||||
// Timeline track that supports changing the game time
|
||||
// The TimeDilation track demonstrates how to
|
||||
// * Support blended and/or extrapolated clips.
|
||||
// * Support changing a Unity static variable from timeline.
|
||||
[TrackColor(0.855f, 0.8623f, 0.87f)]
|
||||
[TrackClipType(typeof(TimeDilationPlayableAsset))]
|
||||
public class TimeDilationTrack : TrackAsset
|
||||
{
|
||||
// Creates a runtime instance of the track, represented by a PlayableBehaviour.
|
||||
// The runtime instance performs mixing on the timeline clips.
|
||||
public override Playable CreateTrackMixer(PlayableGraph graph, GameObject go, int inputCount)
|
||||
{
|
||||
return ScriptPlayable<TimeDilationMixerBehaviour>.Create(graph, inputCount);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c2820263b9b014245b1e66e4fc4a7991
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,16 @@
|
||||
{
|
||||
"name": "Timeline.Samples.TimeDilation",
|
||||
"references": [
|
||||
"GUID:f06555f75b070af458a003d92f9efb00",
|
||||
"GUID:ef63a73cb159aa04997399c27d4eb08a"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b06bcd004155f8343accc449053c5904
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user