1
This commit is contained in:
@@ -5,10 +5,10 @@
|
||||
"GUID:14fe60d984bf9f84eac55c6ea033a8f4",
|
||||
"GUID:21d1eb854b91ade49bc69a263d12bee2",
|
||||
"GUID:49b49c76ee64f6b41bf28ef951cb0e50",
|
||||
"GUID:66d2ae14764cc7d49aad4b16930747c0",
|
||||
"GUID:d8b63aba1907145bea998dd612889d6b",
|
||||
"GUID:709caf8d7fb6ef24bbba0ab9962a3ad0",
|
||||
"GUID:7efac18f239530141802fb139776f333"
|
||||
"GUID:7efac18f239530141802fb139776f333",
|
||||
"GUID:f06555f75b070af458a003d92f9efb00"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
|
109
Src/UnityPluginsSupport/UnitySpline/UnitySplineAnimateAsset.cs
Normal file
109
Src/UnityPluginsSupport/UnitySpline/UnitySplineAnimateAsset.cs
Normal file
@@ -0,0 +1,109 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using Unity.Mathematics;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Playables;
|
||||
using UnityEngine.Splines;
|
||||
using UnityEngine.Timeline;
|
||||
|
||||
namespace BITKit.Spline
|
||||
{
|
||||
public class UnitySplineAnimateBehaviour : PlayableBehaviour
|
||||
{
|
||||
public SplineAnimate splineAnimate { get; set; }
|
||||
public SplineContainer splineContainer { get; set; }
|
||||
public Transform additiveTransform { get; set; }
|
||||
public bool isNormalized;
|
||||
|
||||
public override void OnBehaviourPlay(Playable playable, FrameData info)
|
||||
{
|
||||
if (splineAnimate)
|
||||
splineAnimate.Updated += OnSplineAnimateUpdated;
|
||||
}
|
||||
public override void OnBehaviourPause(Playable playable, FrameData info)
|
||||
{
|
||||
if (splineAnimate)
|
||||
splineAnimate.Updated -= OnSplineAnimateUpdated;
|
||||
}
|
||||
private void OnSplineAnimateUpdated(Vector3 position, Quaternion rotation)
|
||||
{
|
||||
if (splineAnimate == null)
|
||||
return;
|
||||
|
||||
if (BITAppForUnity.IsEditor&& BITAppForUnity.IsPlaying is false)
|
||||
{
|
||||
var transform = splineAnimate.transform;
|
||||
var parent = transform.parent;
|
||||
var localPosition = position;
|
||||
var localRotation = rotation;
|
||||
if (parent != null)
|
||||
{
|
||||
localPosition = transform.parent.worldToLocalMatrix.MultiplyPoint3x4(position);
|
||||
localRotation = Quaternion.Inverse(parent.rotation) * localRotation;
|
||||
|
||||
}
|
||||
|
||||
transform.localPosition = localPosition;
|
||||
transform.localRotation = localRotation;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public override void ProcessFrame(Playable playable, FrameData info, object playerData)
|
||||
{
|
||||
splineAnimate = playerData as SplineAnimate;
|
||||
|
||||
if (!splineAnimate)
|
||||
{
|
||||
Debug.LogException(new NullReferenceException("SplineAnimate is null"));
|
||||
return;
|
||||
}
|
||||
|
||||
var time = (float)playable.GetTime();
|
||||
splineAnimate.Container = splineContainer;
|
||||
|
||||
if (BITAppForUnity.IsEditor is false && BITAppForUnity.IsPlaying is false)
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isNormalized)
|
||||
{
|
||||
splineAnimate.NormalizedTime =info.deltaTime;
|
||||
}
|
||||
else
|
||||
{
|
||||
splineAnimate.ElapsedTime =time;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
[DisplayName("SplineAnimate Clip")]
|
||||
public class UnitySplineAnimateAsset : PlayableAsset,ITimelineClipAsset
|
||||
{
|
||||
private UnitySplineAnimateBehaviour template = new();
|
||||
public ExposedReference<SplineContainer> spline;
|
||||
public AnimationCurve curve;
|
||||
public bool isNormalized;
|
||||
public override Playable CreatePlayable(PlayableGraph graph, GameObject owner)
|
||||
{
|
||||
var playable = ScriptPlayable<UnitySplineAnimateBehaviour>.Create(graph,template);
|
||||
|
||||
var behaviour = playable.GetBehaviour();
|
||||
|
||||
behaviour.splineContainer = spline.Resolve(graph.GetResolver());
|
||||
|
||||
behaviour.isNormalized = isNormalized;
|
||||
|
||||
return playable;
|
||||
}
|
||||
public ClipCaps clipCaps => ClipCaps.None;
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 73c54198788eb884bbac52ca3016892c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,15 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Playables;
|
||||
using UnityEngine.Splines;
|
||||
using UnityEngine.Timeline;
|
||||
|
||||
namespace BITKit.Spline
|
||||
{
|
||||
[TrackBindingType(typeof(SplineAnimate))]
|
||||
[TrackClipType(typeof(UnitySplineAnimateAsset))]
|
||||
public class UnitySplineAnimateTrack : TrackAsset
|
||||
{
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0dbd686f396c8264d82cf8fd2d622597
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -9,5 +9,4 @@ namespace BITKit.Spline
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user