1
This commit is contained in:
53
Src/Unity/Scripts/UX/Player/UXPlayer.cs
Normal file
53
Src/Unity/Scripts/UX/Player/UXPlayer.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using BITKit;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace BITKit.UX
|
||||
{
|
||||
public class UXPlayer : MonoBehaviour
|
||||
{
|
||||
[SerializeReference, SubclassSelector] private IReference rootPath;
|
||||
[SerializeField] private UnityEvent<float> onSetTime;
|
||||
private Slider _playSlider;
|
||||
private Label _currentLabel;
|
||||
private Label _totalLabel;
|
||||
private Button _playButton;
|
||||
private VisualElement _container;
|
||||
private void Start()
|
||||
{
|
||||
_container = GetComponent<UIDocument>().rootVisualElement.Q(rootPath.Value);
|
||||
_playSlider = _container.Q<Slider>("play-slider");
|
||||
_currentLabel = _container.Q<Label>("current-label");
|
||||
_totalLabel = _container.Q<Label>("total-label");
|
||||
_playButton = _container.Q<Button>("play-button");
|
||||
|
||||
_playSlider.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
onSetTime.Invoke(evt.newValue);
|
||||
});
|
||||
}
|
||||
public void SetProgress(float time)
|
||||
{
|
||||
_playSlider.SetValueWithoutNotify(time);
|
||||
}
|
||||
public void SetTime(string time)
|
||||
{
|
||||
_currentLabel.text = time;
|
||||
}
|
||||
public void SetTotalTime(string time)
|
||||
{
|
||||
_totalLabel.text = time;
|
||||
}
|
||||
public void SetPlaying(bool isPlaying)
|
||||
{
|
||||
_playButton.EnableInClassList("playing",isPlaying);
|
||||
}
|
||||
public void SetActive(bool active)
|
||||
{
|
||||
_container.SetActive(active);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user