2026-10-22 12:41:09 +01:00
|
|
|
using SomniumSpace.Bridge.Components;
|
|
|
|
|
using UnityEngine;
|
2026-10-26 18:17:30 +00:00
|
|
|
using UnityEngine.UI;
|
2026-10-22 12:41:09 +01:00
|
|
|
using WebSocketSharp;
|
|
|
|
|
|
2026-10-26 18:17:30 +00:00
|
|
|
namespace UFMTESTING1
|
2026-10-22 12:41:09 +01:00
|
|
|
{
|
2026-10-26 18:17:30 +00:00
|
|
|
public class GetVideoPlayerTextureUI : MonoBehaviour
|
2026-10-22 12:41:09 +01:00
|
|
|
{
|
|
|
|
|
[SerializeField] private GameObject _videoPlayerObject;
|
2026-10-26 18:17:30 +00:00
|
|
|
[SerializeField] private RawImage _rawImage;
|
2026-10-22 12:41:09 +01:00
|
|
|
|
|
|
|
|
private SomniumVideoPlayer _videoPlayerRef;
|
|
|
|
|
private Texture _videoTexture = null;
|
|
|
|
|
|
|
|
|
|
// Start is called before the first frame update
|
|
|
|
|
void Start()
|
|
|
|
|
{
|
|
|
|
|
InvokeRepeating(nameof(GetTexture), 1.0f, 1.0f);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void GetTexture()
|
|
|
|
|
{
|
2026-10-26 18:17:30 +00:00
|
|
|
if (_rawImage == null ||
|
2026-10-22 12:41:09 +01:00
|
|
|
_videoPlayerObject == null)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (_videoPlayerRef == null) // _videoPlayerObject
|
|
|
|
|
_videoPlayerRef = _videoPlayerObject.GetComponent<SomniumVideoPlayer>();
|
|
|
|
|
|
|
|
|
|
if (_videoTexture == null)
|
|
|
|
|
{
|
|
|
|
|
_videoTexture = _videoPlayerRef.GetTexture();
|
|
|
|
|
AssignTexture();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void AssignTexture()
|
|
|
|
|
{
|
2026-10-26 18:17:30 +00:00
|
|
|
_rawImage.texture = _videoTexture;
|
|
|
|
|
}
|
2026-10-22 12:41:09 +01:00
|
|
|
|
2026-10-26 18:17:30 +00:00
|
|
|
private void OnValidate()
|
|
|
|
|
{
|
|
|
|
|
if(_rawImage == null)
|
2026-10-22 12:41:09 +01:00
|
|
|
{
|
2026-10-26 18:17:30 +00:00
|
|
|
_rawImage = GetComponent<RawImage>();
|
2026-10-22 12:41:09 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|