1
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"name": "BITKit.AdvancedCullingSystem.Runtime",
|
||||
"rootNamespace": "",
|
||||
"references": [
|
||||
"GUID:14fe60d984bf9f84eac55c6ea033a8f4",
|
||||
"GUID:a2097016d65c6554fb43a19198fc2220",
|
||||
"GUID:37151e2099022af42afa90e2ee1b768a"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [
|
||||
"BITKit_AdvancedCullingSystem"
|
||||
],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using MeshCombineStudio;
|
||||
using NGS.AdvancedCullingSystem.Dynamic;
|
||||
using UnityEditor.Build;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
#endif
|
||||
namespace BITKit.OpenWorld
|
||||
{
|
||||
public class OpenWorldCombiner : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private MeshCombiner meshCombiner;
|
||||
|
||||
[SerializeField] private UnityEvent onCombiningReady;
|
||||
|
||||
[SerializeField]
|
||||
private bool allowCullingSource = true;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
meshCombiner.onCombiningReady +=x=> onCombiningReady.Invoke();
|
||||
meshCombiner.onCombiningReady += AddCullingSource;
|
||||
}
|
||||
|
||||
private void AddCullingSource(MeshCombiner meshcombiner)
|
||||
{
|
||||
if (allowCullingSource)
|
||||
AddCullingSource();
|
||||
}
|
||||
|
||||
[BIT]
|
||||
private void AddCullingSource()
|
||||
{
|
||||
var reportBuilder = new System.Text.StringBuilder();
|
||||
var renderers = meshCombiner.GetComponentsInChildren<MeshRenderer>(true);
|
||||
reportBuilder.AppendLine($"找到{renderers.Length}个Renderer");
|
||||
foreach (var x in renderers)
|
||||
{
|
||||
if (x.GetComponent<DC_SourceSettings>()) continue;
|
||||
|
||||
x.gameObject.AddComponent<DC_SourceSettings>();
|
||||
|
||||
reportBuilder.AppendLine($"为{x.name}添加了DC_SourceSettings");
|
||||
}
|
||||
|
||||
Debug.Log(reportBuilder.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using MonKey;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BITKit.GameEditor
|
||||
{
|
||||
public class QuickFixFloatModel
|
||||
{
|
||||
[Command(nameof(FixedSelectedFloat), "Fixed Selected Model Position", QuickName = "ins"), MenuItem("Tools/Scenes/Fix Float Model Position")]
|
||||
public static void FixedSelectedFloat()
|
||||
{
|
||||
var transforms = UnityEditor.Selection.transforms;
|
||||
if (transforms is null or {Length:0}) return;
|
||||
|
||||
var reportBuilder = new StringBuilder();
|
||||
reportBuilder.AppendLine($"已选择{transforms.Length}个物体:");
|
||||
foreach (var x in transforms)
|
||||
{
|
||||
if (Physics.Raycast(x.position, Vector3.down, out var hit, 1000) is false) continue;
|
||||
x.position = hit.point;
|
||||
EditorUtility.SetDirty(x);
|
||||
reportBuilder.AppendLine($"已修复{x.name}的位置于{hit.point}");
|
||||
}
|
||||
Undo.RecordObjects(transforms,"修复浮动");
|
||||
|
||||
Debug.Log(reportBuilder);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,7 +11,9 @@
|
||||
"GUID:709caf8d7fb6ef24bbba0ab9962a3ad0",
|
||||
"GUID:7efac18f239530141802fb139776f333",
|
||||
"GUID:508392158bd966c4d9c21e19661a441d",
|
||||
"GUID:f06555f75b070af458a003d92f9efb00"
|
||||
"GUID:f06555f75b070af458a003d92f9efb00",
|
||||
"GUID:4307f53044263cf4b835bd812fc161a4",
|
||||
"GUID:4c25c05f410a3a447a75c3b0909152ef"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
|
||||
@@ -12,21 +12,35 @@ namespace BITKit
|
||||
public string questName;
|
||||
public string qeustDescription;
|
||||
public BBParameter<QuestSystem.Info> output;
|
||||
|
||||
private bool isInitiated;
|
||||
private void Disposed()
|
||||
{
|
||||
if (output.isNoneOrNull) return;
|
||||
if(output.value.State is QuestSystem.State.InProcess)
|
||||
{
|
||||
BIT4Log.Log<CreateQuest>($"任务{output.value.Name}已取消");
|
||||
QuestSystem.Cancel(output.value);
|
||||
}
|
||||
}
|
||||
protected override void OnExecute()
|
||||
{
|
||||
var quest = QuestSystem.Create(questName, qeustDescription);
|
||||
if (output.isDefined)
|
||||
output.SetValue(quest);
|
||||
EndAction();
|
||||
}
|
||||
protected override void OnStop(bool interrupted)
|
||||
{
|
||||
base.OnStop(interrupted);
|
||||
if (interrupted)
|
||||
{
|
||||
if(output.isDefined)
|
||||
QuestSystem.Cancel(output.value);
|
||||
}
|
||||
}
|
||||
|
||||
if(isInitiated)return;
|
||||
agent.As<MonoBehaviour>().destroyCancellationToken.Register(Disposed);
|
||||
isInitiated = true;
|
||||
; }
|
||||
// protected override void OnStop(bool interrupted)
|
||||
// {
|
||||
// base.OnStop(interrupted);
|
||||
// if (!interrupted) return;
|
||||
// if (QuestSystem.quests.TryGetValue(output.value, out var info) &&
|
||||
// info.State == QuestSystem.State.InProcess)
|
||||
// QuestSystem.Cancel(output.value);
|
||||
// }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Animancer;
|
||||
using NodeCanvas.DialogueTrees;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BITKit.NodeCanvas.Director
|
||||
{
|
||||
public class ActorRandomAnimation : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private AnimancerComponent animancerComponent;
|
||||
[SerializeField] private AnimationClip[] clips;
|
||||
private IDialogueActor _actor;
|
||||
private void OnEnable()
|
||||
{
|
||||
_actor = GetComponent<IDialogueActor>();
|
||||
DialogueTree.OnSubtitlesRequest += OnSubtitlesRequest;
|
||||
}
|
||||
private void OnDisable()
|
||||
{
|
||||
DialogueTree.OnSubtitlesRequest -= OnSubtitlesRequest;
|
||||
}
|
||||
|
||||
private void OnSubtitlesRequest(SubtitlesRequestInfo obj)
|
||||
{
|
||||
if(obj.actor != _actor) return;
|
||||
animancerComponent.Stop();
|
||||
var state =animancerComponent.Play(clips.Random());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using NodeCanvas.Framework;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BITKit.NodeCanvas.Director
|
||||
{
|
||||
public class DirectorNode : ActionTask
|
||||
{
|
||||
public BBParameter<string> directorName;
|
||||
public bool isStart;
|
||||
protected override void OnExecute()
|
||||
{
|
||||
base.OnExecute();
|
||||
if(isStart)
|
||||
DirectorService.Register(directorName.value);
|
||||
else
|
||||
DirectorService.UnRegister(directorName.value);
|
||||
EndAction();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Cinemachine;
|
||||
using NodeCanvas.DialogueTrees;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BITKit.NodeCanvas.Director
|
||||
{
|
||||
public class DirectorService : MonoBehaviour
|
||||
{
|
||||
[RuntimeInitializeOnLoadMethod]
|
||||
private static void Reload()
|
||||
{
|
||||
allowDirector.Clear();
|
||||
}
|
||||
private static readonly ValidHandle allowDirector = new();
|
||||
public static void Register(string directorName)
|
||||
{
|
||||
allowDirector.AddElement(directorName);
|
||||
}
|
||||
public static void UnRegister(string directorName)
|
||||
{
|
||||
allowDirector.RemoveElement(directorName);
|
||||
}
|
||||
|
||||
[SerializeField] private CinemachineVirtualCamera directorCamera;
|
||||
|
||||
private Cinemachine3rdPersonFollow _trd;
|
||||
|
||||
private Transform _lastActor;
|
||||
|
||||
private Vector3 _defaultShoulderOffset;
|
||||
private void OnEnable()
|
||||
{
|
||||
DialogueTree.OnSubtitlesRequest += OnSubtitlesRequest;
|
||||
allowDirector.AddListener(OnAllow);
|
||||
|
||||
_trd = directorCamera.GetCinemachineComponent<Cinemachine3rdPersonFollow>();
|
||||
_defaultShoulderOffset = _trd.ShoulderOffset;
|
||||
}
|
||||
private void OnDisable()
|
||||
{
|
||||
DialogueTree.OnSubtitlesRequest -= OnSubtitlesRequest;
|
||||
allowDirector.RemoveListener(OnAllow);
|
||||
}
|
||||
|
||||
private void OnSubtitlesRequest(SubtitlesRequestInfo obj)
|
||||
{
|
||||
if (obj.actor is not MonoBehaviour monoBehaviour) return;
|
||||
var transform1 = monoBehaviour.transform;
|
||||
|
||||
|
||||
directorCamera.LookAt = transform1;
|
||||
directorCamera.Follow = _lastActor ? _lastActor : transform1;
|
||||
|
||||
var newOffset = _defaultShoulderOffset;
|
||||
|
||||
newOffset.z = _lastActor ? _defaultShoulderOffset.z : 3;
|
||||
|
||||
_trd.ShoulderOffset = newOffset;
|
||||
|
||||
_lastActor = transform1;
|
||||
}
|
||||
|
||||
private void OnAllow(bool allow)
|
||||
{
|
||||
if (allow)
|
||||
{
|
||||
directorCamera.Priority = 64;
|
||||
}
|
||||
else
|
||||
{
|
||||
directorCamera.Priority = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,6 @@ namespace BITKit
|
||||
{
|
||||
blackboard.SetVariableValue("HP", hp);
|
||||
}
|
||||
|
||||
public void OnEntryOverride(bool @override)
|
||||
{
|
||||
_allow.SetDisableElements(this,@override);
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace BITKit.NodeCanvas
|
||||
public BBParameter<Transform> target;
|
||||
protected override void OnExecute()
|
||||
{
|
||||
target.SetValue(sensor.value.CurrentTarget);
|
||||
//target.SetValue(sensor.value.CurrentTarget);
|
||||
EndAction();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
"references": [
|
||||
"GUID:14fe60d984bf9f84eac55c6ea033a8f4",
|
||||
"GUID:9c184a1e5cc20654384071dfebc106ed",
|
||||
"GUID:bdb069e155d2f944cb1bf28602b6d4c1"
|
||||
"GUID:bdb069e155d2f944cb1bf28602b6d4c1",
|
||||
"GUID:1193c2664d97cc049a6e4c486c6bce71"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Pinwheel.Griffin;
|
||||
using UnityEditor.Build;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BITKit.WorldChunk
|
||||
{
|
||||
public class PolarisTerrainChunk : WorldChunk
|
||||
{
|
||||
private GTerrainChunk terrain;
|
||||
private MeshRenderer meshRenderer;
|
||||
private bool _isLoaded;
|
||||
private Rect _rect;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
terrain = GetComponent<GTerrainChunk>();
|
||||
meshRenderer = GetComponent<MeshRenderer>();
|
||||
|
||||
var bounds = meshRenderer.bounds;
|
||||
var pos = bounds.center;
|
||||
var size = bounds.size;
|
||||
|
||||
_rect = new Rect(
|
||||
pos.x,
|
||||
pos.z,
|
||||
size.x,
|
||||
size.y
|
||||
);
|
||||
Add(this);
|
||||
destroyCancellationToken.Register(() => { Remove(this); });
|
||||
|
||||
_isLoaded = gameObject.activeSelf;
|
||||
}
|
||||
public override Rect GetRect() => _rect;
|
||||
|
||||
public override void SetActive(bool active)
|
||||
{
|
||||
if (_isLoaded == active) return;
|
||||
terrain.gameObject.SetActive(active);
|
||||
_isLoaded = active;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Pinwheel.Griffin;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BITKit.WorldChunk
|
||||
{
|
||||
public class PolarisTerrainChunkManager : MonoBehaviour
|
||||
{
|
||||
private void Start()
|
||||
{
|
||||
foreach (var x in GetComponentsInChildren<GTerrainChunk>())
|
||||
{
|
||||
x.gameObject.AddComponent<PolarisTerrainChunk>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Pinwheel.Griffin;
|
||||
using Quadtree;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BITKit.OpenWorld
|
||||
{
|
||||
public class PolarisTerrainChunkService : WorldChunkService<PolarisTerrainChunkService>
|
||||
{
|
||||
private class ChunkData:IWorldChunkObject
|
||||
{
|
||||
public Collider Collider { get; set; }
|
||||
public Bounds GetBounds() => Bounds;
|
||||
public Bounds Bounds { get; set; }
|
||||
public Node<IWorldChunkObject> ParentNode { get; set; }
|
||||
public void QuadTree_Root_Initialized(IQuadtreeRoot<IWorldChunkObject, Node<IWorldChunkObject>> root)
|
||||
{
|
||||
}
|
||||
|
||||
public int Id { get; set; }
|
||||
public int Lod
|
||||
{
|
||||
get => lod;
|
||||
set
|
||||
{
|
||||
Collider.enabled = value is 0;
|
||||
lod = value;
|
||||
}
|
||||
}
|
||||
private int lod=-1;
|
||||
}
|
||||
[SerializeField] private GStylizedTerrain[] terrains;
|
||||
protected override void Start()
|
||||
{
|
||||
base.Start();
|
||||
var reporter = new StringBuilder();
|
||||
foreach (var terrain in terrains)
|
||||
{
|
||||
reporter.AppendLine($"正在注册地形 {terrain.name},尺寸:{terrain.TerrainData.Geometry.Width}x{terrain.TerrainData.Geometry.Length}");
|
||||
foreach (var chunk in terrain.GetChunks())
|
||||
{
|
||||
var data =new ChunkData()
|
||||
{
|
||||
Collider = chunk.MeshColliderComponent,
|
||||
Bounds = chunk.MeshColliderComponent.bounds
|
||||
};
|
||||
data.Collider.enabled = false;
|
||||
Register(data);
|
||||
reporter.AppendLine($"注册地形碰撞体 {chunk.name},尺寸:{data.Bounds.size}");
|
||||
}
|
||||
}
|
||||
Debug.Log(reporter);
|
||||
OnTick(Time.deltaTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
18
Assets/BITKit/UnityPluginsSupport/Steamwork/26.asset
Normal file
18
Assets/BITKit/UnityPluginsSupport/Steamwork/26.asset
Normal file
@@ -0,0 +1,18 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: ab6c34283d61d534183f9a63e54f932c, type: 3}
|
||||
m_Name: 26
|
||||
m_EditorClassIdentifier:
|
||||
addressablePath: Cosmetic_26
|
||||
id: 4981
|
||||
defId: 3070
|
||||
type:
|
||||
@@ -12,7 +12,7 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: ab6c34283d61d534183f9a63e54f932c, type: 3}
|
||||
m_Name: Steve
|
||||
m_EditorClassIdentifier:
|
||||
addressablePath: Cosmetics/Steve
|
||||
id: 4980
|
||||
defId: 3070
|
||||
addressablePath: Cosmetic_Steve
|
||||
id: 4984
|
||||
defId: 3072
|
||||
type:
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"name": "BITKit.Extensions.TranslucentImage",
|
||||
"rootNamespace": "",
|
||||
"references": [
|
||||
"GUID:14fe60d984bf9f84eac55c6ea033a8f4",
|
||||
"GUID:6ef4ed8ff60a7aa4bb60a8030e6f4008",
|
||||
"GUID:ff218ee40fe2b8648ab3234d56415557"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [
|
||||
"LeTai_TranslucentImage"
|
||||
],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using LeTai.Asset.TranslucentImage;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BITKit.UX
|
||||
{
|
||||
public class TranslucentService : MonoBehaviour
|
||||
{
|
||||
public static RenderTexture BlurredScreen;
|
||||
[SerializeField] private TranslucentImageSource source;
|
||||
[SerializeField] private RenderTexture blurredScreen;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace BITKit.UX
|
||||
{
|
||||
|
||||
public class TranslucentVisualElement : VisualElement
|
||||
{
|
||||
public new class UxmlFactory : UxmlFactory<TranslucentVisualElement, UxmlTraits> { }
|
||||
public TranslucentVisualElement()
|
||||
{
|
||||
RegisterCallback<GeometryChangedEvent>(OnGeometryChanged);
|
||||
}
|
||||
private void OnGeometryChanged(GeometryChangedEvent evt)
|
||||
{
|
||||
if (style.display.value is not DisplayStyle.Flex) return;
|
||||
style.backgroundImage = new StyleBackground(Background.FromRenderTexture(TranslucentService.BlurredScreen));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.iOS;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace BITKit.UX
|
||||
{
|
||||
public class UXTranslucentService : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Image image;
|
||||
private float alpha;
|
||||
private void Start()
|
||||
{
|
||||
BITAppForUnity.AllowCursor.AddListener(OnCursor);
|
||||
destroyCancellationToken.Register(Dispose);
|
||||
}
|
||||
private void Dispose()
|
||||
{
|
||||
BITAppForUnity.AllowCursor.RemoveListener(OnCursor);
|
||||
}
|
||||
private void OnCursor(bool obj)
|
||||
{
|
||||
image.enabled = obj;
|
||||
if (obj) alpha = 0;
|
||||
}
|
||||
private void Update()
|
||||
{
|
||||
if (BITAppForUnity.AllowCursor.Allow && alpha is not 1)
|
||||
{
|
||||
alpha = Mathf.Clamp01(alpha + Time.deltaTime*5);
|
||||
image.color = new Color(0, 0, 0, alpha);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,10 +5,10 @@
|
||||
"GUID:14fe60d984bf9f84eac55c6ea033a8f4",
|
||||
"GUID:21d1eb854b91ade49bc69a263d12bee2",
|
||||
"GUID:49b49c76ee64f6b41bf28ef951cb0e50",
|
||||
"GUID:66d2ae14764cc7d49aad4b16930747c0",
|
||||
"GUID:d8b63aba1907145bea998dd612889d6b",
|
||||
"GUID:709caf8d7fb6ef24bbba0ab9962a3ad0",
|
||||
"GUID:7efac18f239530141802fb139776f333"
|
||||
"GUID:7efac18f239530141802fb139776f333",
|
||||
"GUID:f06555f75b070af458a003d92f9efb00"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
|
||||
@@ -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,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
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -9,5 +9,4 @@ namespace BITKit.Spline
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user