1
0
mirror of synced 2024-11-28 08:00:50 +01:00
WACVR/Assets/uWindowCapture/Runtime/UwcCursorTexture.cs
2022-05-16 23:38:40 +02:00

36 lines
646 B
C#

using UnityEngine;
namespace uWindowCapture
{
[RequireComponent(typeof(Renderer))]
public class UwcCursorTexture : MonoBehaviour
{
Renderer renderer_;
Material material_;
UwcCursor cursor
{
get { return UwcManager.cursor; }
}
void Awake()
{
renderer_ = GetComponent<Renderer>();
material_ = renderer_.material; // clone
cursor.onTextureChanged.AddListener(OnTextureChanged);
}
void Update()
{
cursor.CreateTextureIfNeeded();
cursor.RequestCapture();
}
void OnTextureChanged()
{
material_.mainTexture = cursor.texture;
}
}
}