Files
MinFt/Client/Assets/Scripts/Common/Timeline/SiblingOrder/SiblingOrderTrack.cs
Liubing\LB 3d8d4d18f3 first commit
先修复一下,错误的场景

删除不必要的钓场资产

修复into场景

update:更新meta文件,修复报错

update:修复资源

修复第一章节建造

修复建造第三章

update:删除多余内容

update:更新README.md

update:还原图标

update:更新README

update:更新配置
2026-04-28 02:17:22 +08:00

71 lines
2.4 KiB
C#

using System;
#if UNITY_EDITOR
using UnityEditor;
#endif
using UnityEngine;
using UnityEngine.Timeline;
using UnityEngine.Playables;
namespace FT.Timeline
{
[Serializable]
[TrackColor(0.565f, 0.753f, 0.565f)]
[TrackClipType(typeof(SiblingOrderPlayableAsset))]
[TrackBindingType(typeof(GameObject))]
[ExcludeFromPreset]
public class SiblingOrderTrack : TrackAsset
{
public override Playable CreateTrackMixer(PlayableGraph graph, GameObject go, int inputCount)
{
return ScriptPlayable<SiblingOrderBehaviour>.Create(graph, inputCount);
}
protected override void OnCreateClip(TimelineClip clip)
{
clip.displayName = "Sibling Order";
base.OnCreateClip(clip);
}
#if UNITY_EDITOR
public override void GatherProperties(PlayableDirector director, IPropertyCollector driver)
{
var boundObject = director.GetGenericBinding(this) as GameObject;
if (boundObject != null)
{
var clips = GetClips();
foreach (var clip in clips)
{
var playableAsset = clip.asset as SiblingOrderPlayableAsset;
if (playableAsset != null && playableAsset.children.Count == 0)
{
RefreshChildren(playableAsset, boundObject);
}
}
}
base.GatherProperties(director, driver);
}
public void RefreshChildren(SiblingOrderPlayableAsset playableAsset, GameObject boundObject)
{
if (playableAsset == null || boundObject == null) return;
playableAsset.children.Clear();
int childCount = boundObject.transform.childCount;
for (int i = 0; i < childCount; i++)
{
var child = boundObject.transform.GetChild(i).gameObject;
var exposedRef = new ExposedReference<GameObject> { defaultValue = child };
exposedRef.exposedName = GUID.Generate().ToString();
playableAsset.children.Add(exposedRef);
var director = boundObject.GetComponent<PlayableDirector>();
if (director != null)
{
director.SetReferenceValue(exposedRef.exposedName, child);
}
}
}
#endif
}
}