1
0
mirror of https://github.com/xiaopeng12138/MaiDXR.git synced 2024-12-18 20:05:52 +01:00
MaiDXR/Assets/uWindowCapture/Runtime/UwcCursorTexture.cs
2022-01-05 19:44:30 +01: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;
}
}
}