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);
|
||||
}
|
||||
}
|
||||
}
|
11
Src/Unity/Scripts/UX/Player/UXPlayer.cs.meta
Normal file
11
Src/Unity/Scripts/UX/Player/UXPlayer.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3a70ff2ae966c9c4eb6e7c25cb59d1a9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user