add pause button for live

This commit is contained in:
CroakFang
2024-01-24 02:22:37 +08:00
parent 9e33d5e829
commit 3a1bf2385e
5 changed files with 272 additions and 18 deletions
+26 -2
View File
@@ -1,23 +1,47 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
public class SliderControl : MonoBehaviour, IPointerDownHandler, IPointerUpHandler
{
public bool is_Touched = false;
public bool is_Outed = false;
public Button PauseButton;
private void Awake()
{
PauseButton.onClick.AddListener(OnPauseButtonClick);
}
private void OnPauseButtonClick()
{
if (is_Touched)
{
OnPointerUp(null);
}
else
{
OnPointerDown(null);
}
}
public void OnPointerDown(PointerEventData eventData)
{
is_Touched = true;
Debug.Log("Dowm");
PauseButton.GetComponentInChildren<Text>().text = "¡ø";
Debug.Log("Pause");
}
public void OnPointerUp(PointerEventData eventData)
{
is_Touched = false;
is_Outed = true;
Debug.Log("Up");
PauseButton.GetComponentInChildren<Text>().text = "¡þ";
Debug.Log("Play");
}
}
@@ -105,12 +105,12 @@ namespace Gallop.Live.Cutt
LiveTimelineKeyIndex curKey = LiveTimelineControl.AlterUpdate_Key(_currentKey, currentTime);
_curIndex = curKey.index;
LiveTimelineKeyCharaMotionData arg = curKey.key as LiveTimelineKeyCharaMotionData;
AnimationClip anim = arg.clip;
if ((curKey != null && _curIndex != -1 && _curIndex != _prevIndex) || Director.instance.sliderControl.is_Touched || Director.instance._syncTime == false || director.IsRecordVMD)
{
LiveTimelineKeyCharaMotionData arg = curKey.key as LiveTimelineKeyCharaMotionData;
AnimationClip anim = arg.clip;
double start;
if(arg.isMotionHeadFrameAll)
{
@@ -124,11 +124,27 @@ namespace Gallop.Live.Cutt
_tempAnim.wrapMode = (arg.loop ? WrapMode.Loop : WrapMode.Default);
_tempAnim[anim.name].time = (float)(start + interval);
if (Mathf.Abs(_prevFrameAnimationTime - currentTime) < 0.01f)
{
if (_tempAnim.IsPlaying(anim.name))
{
_tempAnim.Stop();
}
}
else
{
_tempAnim.Play(anim.name);
}
}
else if (!_tempAnim.IsPlaying(anim.name))
{
_tempAnim.Play(anim.name);
}
_prevIndex = _curIndex;
}
_prevFrameAnimationTime = currentTime;
}
}
}