// Only skill mode worked public void BlendTo(string path) { var track = SkillHostTrack as XAnimationTrack; AnimClipData data = null; if (track) { blendPlayableOutput = track.playableOutput; blendMixPlayable = track.mixPlayable; mixJob = track.mixJob; var clip = track.GetPlayingPlayable(out var tick) as XAnimationClip; if (clip != null) { var p = clip.playable; data = (AnimClipData)clip.data; data.trim_start = tick; data.duration = Mathf.Min(tick + 0.1f, data.duration); data.start = 0; } } blending = true; Dispose(true); ReadConf(path); if (config != null) { if (config.skillHostTrack <= 0) { Debug.LogError("not config skill host " + path); return; } if (data != null) { var clips = config.tracks[config.skillHostTrack].clips; var nc = new ClipData[clips.Length + 1]; nc[0] = data; for (int i = 1; i < clips.Length + 1; i++) { nc[i] = clips[i - 1]; } config.tracks[config.skillHostTrack].clips = nc; } Initial(config, PlayMode.Skill); } SetPlaying(true); }
public override void OnBind() { if (bindObj && XSeqence.graph.IsValid()) { var amtor = bindObj.GetComponent <Animator>(); var transforms = amtor.transform.GetComponentsInChildren <Transform>(); var numTransforms = transforms.Length - 1; if (seqence.IsHostTrack(this) && seqence.blendPlayableOutput.IsOutputValid()) { playableOutput = seqence.blendPlayableOutput; mixPlayable = seqence.blendMixPlayable; mixJob = seqence.mixJob; } else { var handles = new NativeArray <TransformStreamHandle>(numTransforms, Allocator.Persistent, NativeArrayOptions.UninitializedMemory); for (var i = 0; i < numTransforms; ++i) { handles[i] = amtor.BindStreamTransform(transforms[i + 1]); } mixJob = new MixerJob() { handles = handles, weight = 1.0f }; AnimationTrackData Data = data as AnimationTrackData; bindObj.transform.position = Data.pos; bindObj.transform.rotation = Quaternion.Euler(0, Data.rotY, 0); playableOutput = AnimationPlayableOutput.Create(XSeqence.graph, "AnimationOutput", amtor); mixPlayable = AnimationScriptPlayable.Create(XSeqence.graph, mixJob); mixPlayable.SetProcessInputs(false); } playableOutput.SetSourcePlayable(mixPlayable); } base.OnBind(); }